refactor(config): deduplicate exec helpers between secret-store, writer and config-resolver
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
Start by diffing src/config/secret-store.ts, src/config/writer.ts and packages/config-resolver/src/index.ts to confirm the duplicated helpers (shellEscape, psEncodedCommand, PRINTABLE_ASCII_RE, execOpts, the _testSetExecSync/_testSetPlatform seams). The issue says not to start until #664 and the icacls-to-execFile change for writer.ts have landed, so re-check those first. Done means no helper body is defined in more than one file, existing tests pass with only import paths changed, and the lazy load in loader.ts is preserved.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Process-exec helpers are copy-pasted across three files. Diffed and confirmed byte-identical:
shellEscapeandpsEncodedCommand:src/config/secret-store.ts:88-95andpackages/config-resolver/src/index.ts:139-146.PRINTABLE_ASCII_RE:secret-store.ts:57andconfig-resolver/src/index.ts:184.execOpts:config-resolver/src/index.ts:135-137andsrc/config/writer.ts:59-61are identical.secret-store.ts:77-86is the same with an optionalinput._execSync/_platformplus the_testSetExecSync/_testSetPlatformseams:secret-store.ts:125-148,config-resolver/src/index.ts:132-133,341-351,writer.ts:42-57.
secret-store.ts also defines spawnOpts (L110-119). Its body is identical to execOpts (L77-86); only the return type differs. The security -w … doc comment at L101-106 describes the spawnSync(SETSID_PERL, …) call in MacKeychainStore.put (~L184-195), but it is attached to the SETSID_PERL constant.
Sequencing (do NOT start yet)
- After #664's fix. This comment proposes moving
secret-store.tstoexecFile/spawnargv. That deletes every POSIXshellEscapeuse in that file (L214, 239, 252, 283, 294) and probablyexecOpts/spawnOptsas they are today. - After the icacls →
execFilePR forwriter.ts.writer.tsonly uses_execSyncforicacls(L238). Once that change lands, itsexecOptscopy and_testSetExecSyncseam either go away or change shape.
What remains after both
These are estimates and depend on how #664 lands:
psEncodedCommand(4 lines) is still in bothsecret-store.ts(Windows Credential Manager: L313, 330, 342) andconfig-resolver(L297).PRINTABLE_ASCII_RE(1 line) is in both.shellEscapestays only inconfig-resolver(L215, 238, 264) unless the resolver also moves to argv. It would then no longer be duplicated.- The
_testSetExecSync/_testSetPlatformseams (~10 lines) remain in each file that still shells out.
That leaves roughly 15-25 duplicated lines in total. This is low priority. Once the prerequisites land, re-run the diff first. If only psEncodedCommand and the regex are left, it may be cheaper to leave them and close this issue.
Proposal
- Export
psEncodedCommand(andPRINTABLE_ASCII_RE, plus the exec options builder if one survives) from@elastic/config-resolver, which is already a workspace dependency, and import them insecret-store.ts. Don't add asrc/lib/proc.ts: the package can't import fromsrc/, so the package has to be the source. - Keep it a cheap import.
loader.ts:31,381lazy-loads@elastic/config-resolverto keep the help path fast.secret-store.tsis only reached fromconfigcommands andcloud/credentials.ts, so a static import there should be fine. Check this against ARCHITECTURE.md before merging. - Collapse
execOpts/spawnOptsinto one builder if both still exist. - Move the
security -wcomment onto thespawnSynccall it describes.
Acceptance criteria
- No helper function body is defined in more than one of
src/config/secret-store.ts,src/config/writer.ts,packages/config-resolver/src/index.ts. - At most one exec options builder in
secret-store.ts. - The
security -wcomment sits next to thespawnSynccall inMacKeychainStore.put. - No behavior change. Existing secret-store, writer and config-resolver tests pass unmodified, apart from import paths.
- No regression in help-path startup time (the lazy-load in
loader.tsis preserved).
Related
#664, plus the pending icacls → execFile PR for src/config/writer.ts.
authored by Pi Coding Agent (Claude Opus 5.5)
- Ngôn ngữ chính
- TypeScript
- Star
- 51
- Fork
- 27
- Merge trung bình
- 22 giờ 48 phút
- Pull request đã merge (30 ngày)
- 48
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của elastic/cli
-
tracking
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feat: ship skills/elastic/SKILL.md for agent invocationCó thể đã có người làm @onatozmenn đã nhận 29 ngày trước. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
elastic/cli#628 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
elastic/cli#617 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tracking
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Deduplicate lazy stub-leaf and stub-swap logic in es/kb registerCó thể đã có người làm @JoshMock đã nhận 10 ngày trước. Đang mởStale
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
elastic/cli#734 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
DRY stats column groupingsĐang mởready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
wheresrhys/totf#1214 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CodeChefVIT/ffcs#281 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
endora-commerce/endora-commerce#451 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
vetro-protocol/vetro-monorepo#1007 ·
Maintainer thường phản hồi trong vòng 1 ngày