leerness 1.9.385 → 1.9.387
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +5 -5
- package/bin/harness.js +16 -19
- package/lib/pure-utils.js +31 -1
- package/package.json +1 -1
- package/scripts/e2e.js +53 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.387 — 2026-06-06 — --json 일관성 연장: incident/runs list 빈 케이스 구조화 (UR-0088)
|
|
4
|
+
|
|
5
|
+
**🔌 `incident list` / `runs list` 의 빈 상태도 `--json` 시 `{total:0,items:[]}` 출력 — AI 에이전트가 빈 프로젝트에서 사람용 텍스트를 파싱하다 실패하던 일관성 결함 해소.**
|
|
6
|
+
|
|
7
|
+
### 배경 (5번째 외부평가 UR-0085 테마 자체 확장)
|
|
8
|
+
status/verify --json(1.9.384) 수정 후, 나머지 읽기형 명령 12종의 --json 커버리지를 자체 점검. 10종은 정상이나 `incident list` / `runs list` 는 디렉토리 미존재(빈 프로젝트) 시 `--json` 검사 전에 사람용 텍스트(`(runs 없음 …)`)를 출력하고 조기 return → AI 에이전트가 JSON.parse 실패.
|
|
9
|
+
|
|
10
|
+
### 구현
|
|
11
|
+
- `runsListCmd` / `incidentListCmd` 의 빈 케이스 조기 return 을 `has('--json')` 인지하도록 수정 → 빈 케이스도 `{ total: 0, items: [] }`(데이터 케이스와 동일 스키마) 출력. `--json` 없으면 기존 사람용 텍스트 그대로.
|
|
12
|
+
|
|
13
|
+
### 검증 (회귀 0)
|
|
14
|
+
- **selftest 132→133 PASS** (incident/runs list 빈 케이스 behavioral --json 파싱 → total=0/items=[]).
|
|
15
|
+
- **E2E 331→332 PASS** (fresh init 에서 incident/runs list --json → `{total:0,items:[]}` + 사람용 텍스트(JSON 아님) 보존).
|
|
16
|
+
- 실측: 읽기형 12종 중 10종 기존 정상 + 2종 수정 = --json 일관성 완비.
|
|
17
|
+
|
|
18
|
+
## 1.9.386 — 2026-06-06 — 5번째 외부평가: secret scan env-family 포함 + gitignore git-일치 (UR-0087)
|
|
19
|
+
|
|
20
|
+
**🔐 `.env.bad` / `.env.local` / `.env.production` 등 env-variant 파일의 시크릿을 스캔 — 통째 스킵되던 보안 false-negative 해소 + gitignore 강등을 git 실제 동작에 맞춤.**
|
|
21
|
+
|
|
22
|
+
### 배경 (5번째 외부평가, GPT-5.5 web · "참고하되 맹신 X")
|
|
23
|
+
"secret scan 이 `.env.bad` 의 OpenAI-key-like 문자열을 놓쳤다." 자체 재현으로 **두 겹의 원인** 발견:
|
|
24
|
+
1. **스캔 제외(주원인)**: `.env.bad` 의 extname 은 `.bad`(.env.local→`.local`, .env.production→`.production`) 라 `SCAN_TEXT_EXT` 에 없어 **파일 자체가 스킵**. bare `.env`(extname `''`)만 스캔되고 있었음.
|
|
25
|
+
2. **과잉 강등**: 1.9.365(CV-6) 의 `.env` 관행 휴리스틱이 `.gitignore` 에 `.env` 만 있어도 모든 `.env.*` 를 보호(info 강등)로 처리 — 그러나 `git check-ignore .env.bad`(gitignore=`.env`) 는 **미무시(커밋 대상)**.
|
|
26
|
+
|
|
27
|
+
### 구현
|
|
28
|
+
1. **env-family 스캔 포함**: extname 대신 basename `/^\.env(\.|$)/` 매칭 → `.env` / `.env.local` / `.env.bad` / `.env.production` 모두 스캔.
|
|
29
|
+
2. **`_gitignoreMatch` + `_globToRe` 순수 추출**(lib/pure-utils.js, UR-0025): 정확매칭 / glob(`*`→`[^/]*`) / dir(`/`) 지원. 1.9.365 과잉 휴리스틱 제거 → **git 실제 동작 일치**: bare `.env` 는 `.env` 만 보호, `.env.bad` 는 커밋 대상(실패). `.env.*` / `.env*` 명시 시에만 `.env.bad` 보호.
|
|
30
|
+
|
|
31
|
+
### 검증 (회귀 0)
|
|
32
|
+
- **selftest 131→132 PASS** (`_gitignoreMatch` 15종 매트릭스 핵심 `.env↛.env.bad`=false + env-family 스캔 와이어 + reference-equality).
|
|
33
|
+
- **E2E 330→331 PASS** (① `.env.bad`+gitignore=`.env`→커밋대상 exit1 + ② `.env`→강등 exit0(CV-6 보존) + ③ `.env.bad`+gitignore=`.env.*`→glob 강등 exit0).
|
|
34
|
+
- 실측 15/15 gitignore 매칭(git 일치) + `git check-ignore` 교차확인.
|
|
35
|
+
|
|
3
36
|
## 1.9.385 — 2026-06-06 — 5번째 외부평가: contract verify markdown bullet 함수 파서 (UR-0086)
|
|
4
37
|
|
|
5
38
|
**📐 `contract verify` spec 파서가 markdown bullet `- name(args)` 함수 선언을 감지 — 실제 누락을 통과시키던 false-negative 해소.**
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **AI 코딩 에이전트의 거짓 완료·중복·망각·충돌을 막아주는 검수·기억·협업 CLI 하네스.**
|
|
4
4
|
> **A CLI harness that stops AI coding agents from faking completion, duplicating work, forgetting context, and colliding.**
|
|
5
5
|
|
|
6
|
-
[](https://www.npmjs.com/package/leerness) [](https://www.npmjs.com/package/leerness) []() []() []() []() []() []()
|
|
7
7
|
|
|
8
8
|
```
|
|
9
9
|
╔══════════════════════════════════════════════════════════════╗
|
|
@@ -471,7 +471,7 @@ MIT — © leerness contributors
|
|
|
471
471
|
<!-- leerness:project-readme:start -->
|
|
472
472
|
## Leerness Project Harness
|
|
473
473
|
|
|
474
|
-
이 프로젝트는 Leerness v1.9.
|
|
474
|
+
이 프로젝트는 Leerness v1.9.387 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
|
|
475
475
|
|
|
476
476
|
### 정체성 — AI 에이전트 운영 레이어 (UR-0030)
|
|
477
477
|
|
|
@@ -525,7 +525,7 @@ leerness memory restore decision <date|title>
|
|
|
525
525
|
|
|
526
526
|
### MCP server (외부 AI 통합)
|
|
527
527
|
|
|
528
|
-
Leerness v1.9.
|
|
528
|
+
Leerness v1.9.387는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **85개 도구**를 노출:
|
|
529
529
|
|
|
530
530
|
```jsonc
|
|
531
531
|
// 카테고리별
|
|
@@ -546,7 +546,7 @@ Leerness v1.9.385는 stdio JSON-RPC MCP server를 내장합니다 — Claude Cod
|
|
|
546
546
|
`<<autonomous-loop-dynamic>>` 신호만 보내면 AI가:
|
|
547
547
|
1) 다음 라운드 후보 선정 → 2) 코드 변경 → 3) stress-v* 신규 작성 + 누적 회귀 → 4) e2e 219/219 → 5) npm pack + git tag + GitHub release → 6) main 자동 push (1.9.140+) → 7) session close → 8) 다음 라운드 예약.
|
|
548
548
|
|
|
549
|
-
현재 누적: **70 라운드 (1.9.40 → 1.9.
|
|
549
|
+
현재 누적: **70 라운드 (1.9.40 → 1.9.387)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
|
|
550
550
|
|
|
551
551
|
### 성능 가이드 (1.9.140 측정)
|
|
552
552
|
|
|
@@ -584,6 +584,6 @@ leerness release pack --close --auto-main-push
|
|
|
584
584
|
- `.harness/session-handoff.md`: 다음 세션 인수인계 (자동 작성)
|
|
585
585
|
- `.harness/lessons.md` / `decisions.md` / `rules.md`: 영구 메모리 (5 surface)
|
|
586
586
|
|
|
587
|
-
Last synced by Leerness v1.9.
|
|
587
|
+
Last synced by Leerness v1.9.387: 2026-06-06
|
|
588
588
|
<!-- leerness:project-readme:end -->
|
|
589
589
|
|
package/bin/harness.js
CHANGED
|
@@ -23,13 +23,13 @@ const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, _mergeLines, _merg
|
|
|
23
23
|
_personaSummaries, _translate,
|
|
24
24
|
_decisionsFromMd, _renderDecisionsMd, _renderLessonsMd,
|
|
25
25
|
_withBuiltinSource, _esc, _roadmapTokenStyles, _parseSkillMd,
|
|
26
|
-
_migrationGuideText, _parseContractSpec } = require('../lib/pure-utils'); // 1.9.318~
|
|
26
|
+
_migrationGuideText, _parseContractSpec, _gitignoreMatch } = require('../lib/pure-utils'); // 1.9.318~386 (UR-0025/0053/0075/0086/0087): 순수 유틸 모듈 분리
|
|
27
27
|
// 1.9.304 (UR-0025): 순수 분석/검증 함수 모듈 분리.
|
|
28
28
|
const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInGit, _epistemicHonestyCheck } = require('../lib/analyzers');
|
|
29
29
|
// 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
|
|
30
30
|
const { CAPABILITY_SURFACE, POWERFUL_COMMANDS, ADAPTERS, REUSE_CATEGORIES, REUSE_CHECKLIST, _DEFAULT_PLATFORM_CONSTRAINTS, _DEFAULT_DOMAIN_CATALOG, _LSP_LANG_PATTERNS, OPTIMISM_PATTERNS, BUILT_IN_PERSONAS, STRINGS, BUILTIN_CATALOG, ROADMAP_STATUS_LABEL, ROADMAP_STATUS_COLOR, SECRET_PATTERNS, MERGE_OVERWRITE_FILES, MINIMAL_SKIP_KEYS, REQUIRED_WORKSPACE_FILES, KEYWORD_STOPWORDS, SKILL_CATALOG_PRESETS } = require('../lib/catalogs'); // 1.9.344/368/369 (UR-0025): catalog 분리 (MERGE_OVERWRITE_FILES/MINIMAL_SKIP_KEYS 포함)
|
|
31
31
|
|
|
32
|
-
const VERSION = '1.9.
|
|
32
|
+
const VERSION = '1.9.387';
|
|
33
33
|
|
|
34
34
|
// 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
|
|
35
35
|
// 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
|
|
@@ -2988,6 +2988,8 @@ function _selfTestCases() {
|
|
|
2988
2988
|
{ name: 'UR-0025 큰핸들러토대: lib/io.js fs 프리미티브(read/writeUtf8/exists/mkdirp/append/rel/absRoot) 분리 + round-trip (1.9.383)', run: () => { const io = require('../lib/io'); const exp = ['absRoot', 'exists', 'read', 'readBuf', 'mkdirp', 'writeUtf8', 'append', 'rel'].every(k => typeof io[k] === 'function') && io.read === read && io.writeUtf8 === writeUtf8 && io.exists === exists; const src = read(__filename); const moved = !/^function writeUtf8\(p, s\) \{/m.test(src) && !/^function read\(p\) \{/m.test(src) && !/^function exists\(p\) \{/m.test(src); const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_io_')); let rt = false; try { const f = path.join(tmp, 'a', 'b.txt'); io.writeUtf8(f, '한글RT'); rt = io.exists(f) && io.read(f) === '한글RT' && io.rel(tmp, f) === 'a/b.txt'; } finally { try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } return exp && moved && rt; } },
|
|
2989
2989
|
{ name: '5th외부평가/UR-0085: status --json 구조화 출력 + verify --json 와이어 (1.9.384)', run: () => { if (typeof status !== 'function' || typeof verify !== 'function') return false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_sj_')); const save = process.argv; const _w = process.stdout.write; let so = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'status', tmp, '--json']; process.stdout.write = s => { so += s; return true; }; status(tmp); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } let sj; try { sj = JSON.parse(so); } catch {} const statusOk = !!sj && typeof sj.total === 'number' && typeof sj.present === 'number' && 'healthy' in sj && Array.isArray(sj.missing); const src = read(__filename); const verifyWired = /function verify\(root\) \{[\s\S]*?has\('--json'\)[\s\S]*?JSON\.stringify\(\{ ok:/.test(src); return statusOk && verifyWired; } },
|
|
2990
2990
|
{ name: '5th외부평가/UR-0086: _parseContractSpec markdown bullet 함수 감지 + 순수 추출 (1.9.385)', run: () => { const m = require('../lib/pure-utils'); if (m._parseContractSpec !== _parseContractSpec) return false; const p = _parseContractSpec('# Spec\n- add(a,b)\n* subtract(a,b)\n1. multiply(a,b)\nfunction legacy(x)\n`mentioned(`\ntick.amount\n'); const declOk = ['add', 'subtract', 'multiply', 'legacy'].every(n => p.declared.includes(n)) && p.declared.length === 4; const menOk = p.mentioned.includes('mentioned') && !p.declared.includes('mentioned'); const fieldOk = p.fields.includes('amount'); const fpOk = _parseContractSpec('- 합계 (a+b)\n- result (total)\n- foo: bar(x)\n**bold**').declared.length === 0; const src = read(__filename); const moved = src.includes('_parseContractSpec(specText)') && !/specText\.matchAll\(\/function/.test(src); return declOk && menOk && fieldOk && fpOk && moved; } },
|
|
2991
|
+
{ name: '5th외부평가/UR-0087: _gitignoreMatch git 일치(.env↛.env.bad) + env-family 스캔 (1.9.386)', run: () => { const m = require('../lib/pure-utils'); if (m._gitignoreMatch !== _gitignoreMatch) return false; const gm = _gitignoreMatch; const semOk = gm('.env', '.env') === true && gm('.env', '.env.bad') === false && gm('.env', '.env.local') === false && gm('.env.*', '.env.bad') === true && gm('.env*', '.env') === true && gm('*.pem', 'k.pem') === true && gm('src/', 'src/a.txt') === true; const src = read(__filename); const envFamilyScan = src.includes('const isEnvFamily =') && src.includes('!SCAN_TEXT_EXT.has(ext) && !isEnvFamily'); const delegated = src.includes('return _gitignoreMatch(gi, fileRel)'); return semOk && envFamilyScan && delegated; } },
|
|
2992
|
+
{ name: 'UR-0088 5th외부평가 일관성: incident/runs list 빈 케이스 --json 구조화 (1.9.387)', run: () => { if (typeof incidentListCmd !== 'function' || typeof runsListCmd !== 'function') return false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_lj_')); const save = process.argv; const _w = process.stdout.write; let io = '', ro = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'incident', 'list', '--json']; process.stdout.write = s => { io += s; return true; }; incidentListCmd(tmp); process.stdout.write = _w; process.argv = ['node', 'h', 'runs', 'list', '--json']; process.stdout.write = s => { ro += s; return true; }; runsListCmd(tmp); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } let ij, rj; try { ij = JSON.parse(io); rj = JSON.parse(ro); } catch {} return !!ij && ij.total === 0 && Array.isArray(ij.items) && !!rj && rj.total === 0 && Array.isArray(rj.items); } },
|
|
2991
2993
|
{ name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
|
|
2992
2994
|
];
|
|
2993
2995
|
}
|
|
@@ -7257,23 +7259,13 @@ function* walk(root, base = root, depth = 0, extras = null) {
|
|
|
7257
7259
|
else yield p;
|
|
7258
7260
|
}
|
|
7259
7261
|
}
|
|
7260
|
-
// 1.9.365 (외부리뷰 CV-6/UR-0081): 간이 .gitignore 매칭 — gitignored
|
|
7261
|
-
//
|
|
7262
|
+
// 1.9.365 (외부리뷰 CV-6/UR-0081): 간이 .gitignore 매칭 — gitignored 파일의 시크릿은 커밋 제외(설계상 안전) → 실패 대신 info.
|
|
7263
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): 순수 _gitignoreMatch 로 위임 + bare '.env' → 모든 '.env.*' 과잉보호 제거.
|
|
7264
|
+
// git 실제 동작 일치: '.env' 는 '.env' 만 보호, '.env.bad' 는 커밋 대상(실패). '.env.*'/'.env*' 명시 시에만 보호.
|
|
7262
7265
|
function _isLikelyGitignored(root, fileRel) {
|
|
7263
7266
|
let gi;
|
|
7264
7267
|
try { gi = read(path.join(root, '.gitignore')); } catch { return false; }
|
|
7265
|
-
|
|
7266
|
-
const base = relPosix.split('/').pop();
|
|
7267
|
-
for (let pat of gi.split(/\r?\n/)) {
|
|
7268
|
-
pat = pat.trim();
|
|
7269
|
-
if (!pat || pat.startsWith('#') || pat.startsWith('!')) continue;
|
|
7270
|
-
const p = pat.replace(/^\/+|\/+$/g, '');
|
|
7271
|
-
if (p === relPosix || p === base) return true;
|
|
7272
|
-
if (pat === '.env' && /^\.env(\.|$)/.test(base)) return true; // .env 관행상 .env.* 도 보호
|
|
7273
|
-
if (p.startsWith('*.') && base.endsWith(p.slice(1))) return true;
|
|
7274
|
-
if (pat.endsWith('/') && (relPosix === p || relPosix.startsWith(p + '/'))) return true;
|
|
7275
|
-
}
|
|
7276
|
-
return false;
|
|
7268
|
+
return _gitignoreMatch(gi, fileRel);
|
|
7277
7269
|
}
|
|
7278
7270
|
function scanSecrets(root) {
|
|
7279
7271
|
root = absRoot(root);
|
|
@@ -7283,7 +7275,10 @@ function scanSecrets(root) {
|
|
|
7283
7275
|
try { _iter = fs.statSync(root).isFile() ? [root] : walk(root); } catch { _iter = walk(root); }
|
|
7284
7276
|
for (const file of _iter) {
|
|
7285
7277
|
const ext = path.extname(file).toLowerCase();
|
|
7286
|
-
|
|
7278
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): env-family(.env / .env.local / .env.bad / .env.production …)는
|
|
7279
|
+
// extname 이 .bad/.local/.production 라 SCAN_TEXT_EXT 에 없어 통째로 스킵되던 FN → basename 으로 강제 포함.
|
|
7280
|
+
const isEnvFamily = /^\.env(\.|$)/.test(path.basename(file));
|
|
7281
|
+
if (!SCAN_TEXT_EXT.has(ext) && !isEnvFamily) continue;
|
|
7287
7282
|
let text;
|
|
7288
7283
|
try { text = read(file); } catch { continue; }
|
|
7289
7284
|
if (text.length > 1024 * 1024) continue;
|
|
@@ -17692,7 +17687,8 @@ function runCommandSafe(cmd, args, opts) {
|
|
|
17692
17687
|
function runsListCmd(root) {
|
|
17693
17688
|
root = absRoot(root || process.cwd());
|
|
17694
17689
|
const dir = _runsDir(root);
|
|
17695
|
-
|
|
17690
|
+
// 1.9.387 (UR-0088, 5번째 외부평가 일관성): 빈 케이스도 --json 시 구조화 출력(AI 에이전트가 사람용 텍스트 파싱 실패 방지).
|
|
17691
|
+
if (!exists(dir)) { if (has('--json')) log(JSON.stringify({ total: 0, items: [] }, null, 2)); else log('(runs 없음 — leerness agent 호출 시 자동 기록됨)'); return; }
|
|
17696
17692
|
const files = fs.readdirSync(dir).filter(f => f.endsWith('.jsonl')).sort().reverse();
|
|
17697
17693
|
if (has('--json')) {
|
|
17698
17694
|
const items = files.slice(0, 50).map(f => {
|
|
@@ -19518,7 +19514,8 @@ function _saveIncident(root, payload) {
|
|
|
19518
19514
|
function incidentListCmd(root) {
|
|
19519
19515
|
root = absRoot(root || process.cwd());
|
|
19520
19516
|
const dir = _incidentsDir(root);
|
|
19521
|
-
|
|
19517
|
+
// 1.9.387 (UR-0088, 5번째 외부평가 일관성): 빈 케이스도 --json 시 구조화 출력.
|
|
19518
|
+
if (!exists(dir)) { if (has('--json')) log(JSON.stringify({ total: 0, items: [] }, null, 2)); else log('(incidents 없음 — leerness webhook serve 로 수신 가능)'); return; }
|
|
19522
19519
|
const files = fs.readdirSync(dir).filter(f => f.endsWith('.json')).sort().reverse();
|
|
19523
19520
|
if (has('--json')) {
|
|
19524
19521
|
const items = files.slice(0, 50).map(f => { try { return JSON.parse(read(path.join(dir, f))); } catch { return null; } }).filter(Boolean);
|
package/lib/pure-utils.js
CHANGED
|
@@ -927,7 +927,9 @@ module.exports = {
|
|
|
927
927
|
// 1.9.355 (UR-0075 Phase A): 크로스버전 마이그레이션 가이드
|
|
928
928
|
_migrationGuideText,
|
|
929
929
|
// 1.9.385 (UR-0086, 5th외부평가): contract spec 순수 파서 (markdown bullet 함수 선언 감지)
|
|
930
|
-
_parseContractSpec
|
|
930
|
+
_parseContractSpec,
|
|
931
|
+
// 1.9.386 (UR-0087, 5th외부평가): 간이 .gitignore 매칭 + glob (bare .env → .env.* 과잉보호 제거)
|
|
932
|
+
_gitignoreMatch, _globToRe
|
|
931
933
|
};
|
|
932
934
|
|
|
933
935
|
// 1.9.355 (UR-0075 Phase A): AI 에이전트용 크로스버전 마이그레이션 안전 워크플로 가이드 (순수 텍스트). 임시설치 + --path + 백업 + diff 검증.
|
|
@@ -986,3 +988,31 @@ function _parseContractSpec(specText) {
|
|
|
986
988
|
for (const m of s.matchAll(/tick\.([A-Za-z_$][\w$]*)/g)) fields.add(m[1]);
|
|
987
989
|
return { declared: [...declared], mentioned: [...mentioned], fields: [...fields] };
|
|
988
990
|
}
|
|
991
|
+
|
|
992
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): 간이 glob → 정규식. '*' → [^/]* (경로구분 제외), 나머지는 리터럴.
|
|
993
|
+
function _globToRe(glob) {
|
|
994
|
+
const esc = String(glob).replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^/]*');
|
|
995
|
+
return new RegExp('^' + esc + '$');
|
|
996
|
+
}
|
|
997
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): 간이 .gitignore 매칭 (순수). full semantics 아님 — 정확매칭 / glob(*) / dir(/) 지원.
|
|
998
|
+
// 1.9.365 의 과잉 휴리스틱(bare '.env' → 모든 '.env.*' 보호) 제거 → git 실제 동작과 일치:
|
|
999
|
+
// '.env' 는 '.env' 만 매칭(.env.bad 미보호 = 커밋 대상). '.env.*' / '.env*' 같은 명시 glob 만 .env.bad 보호.
|
|
1000
|
+
function _gitignoreMatch(giText, fileRel) {
|
|
1001
|
+
if (!giText) return false;
|
|
1002
|
+
const relPosix = String(fileRel).replace(/\\/g, '/');
|
|
1003
|
+
const base = relPosix.split('/').pop();
|
|
1004
|
+
for (let pat of String(giText).split(/\r?\n/)) {
|
|
1005
|
+
pat = pat.trim();
|
|
1006
|
+
if (!pat || pat.startsWith('#') || pat.startsWith('!')) continue;
|
|
1007
|
+
const isDir = pat.endsWith('/');
|
|
1008
|
+
const p = pat.replace(/^\/+|\/+$/g, '');
|
|
1009
|
+
if (!p) continue;
|
|
1010
|
+
if (p === relPosix || p === base) return true; // 정확 매칭 (.env → .env)
|
|
1011
|
+
if (isDir && (relPosix === p || relPosix.startsWith(p + '/'))) return true; // dir/
|
|
1012
|
+
if (p.includes('*')) { // glob: *.pem / .env.* / .env*
|
|
1013
|
+
const re = _globToRe(p);
|
|
1014
|
+
if (re.test(p.includes('/') ? relPosix : base)) return true;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return false;
|
|
1018
|
+
}
|
package/package.json
CHANGED
package/scripts/e2e.js
CHANGED
|
@@ -5395,5 +5395,58 @@ total++;
|
|
|
5395
5395
|
if (!ok) failed++;
|
|
5396
5396
|
}
|
|
5397
5397
|
|
|
5398
|
+
// 1.9.386 회귀 (5번째 외부평가/UR-0087): secret scan env-family 포함 + gitignore git-일치 (.env↛.env.bad 미보호=커밋대상)
|
|
5399
|
+
total++;
|
|
5400
|
+
{
|
|
5401
|
+
let ok = false;
|
|
5402
|
+
try {
|
|
5403
|
+
const key = 'OPENAI_API_KEY=sk-proj-abc123def456ghi789jkl012mno345pqr678stuvwx\n';
|
|
5404
|
+
// ① .env.bad(extname .bad, 종전 스킵) + gitignore=.env → 스캔됨 + 커밋대상 실패(exit1). git 실제 동작 일치(핵심 FN fix)
|
|
5405
|
+
const d1 = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-envbad-'));
|
|
5406
|
+
fs.writeFileSync(path.join(d1, '.gitignore'), '.env\n');
|
|
5407
|
+
fs.writeFileSync(path.join(d1, '.env.bad'), key);
|
|
5408
|
+
const r1 = cp.spawnSync(process.execPath, [CLI, 'scan', 'secrets', d1], { encoding: 'utf8', timeout: 20000 });
|
|
5409
|
+
const flaggedOk = r1.status === 1 && /\.env\.bad/.test(r1.stdout || '') && /OpenAI/.test(r1.stdout || '');
|
|
5410
|
+
// ② .env + gitignore=.env → 강등 info(exit0). 기존 CV-6(1.9.365) 보존
|
|
5411
|
+
const d2 = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-envok-'));
|
|
5412
|
+
fs.writeFileSync(path.join(d2, '.gitignore'), '.env\n');
|
|
5413
|
+
fs.writeFileSync(path.join(d2, '.env'), 'TOKEN=npm_abcdefghijklmnopqrstuvwxyz0123456789\n');
|
|
5414
|
+
const r2 = cp.spawnSync(process.execPath, [CLI, 'scan', 'secrets', d2], { encoding: 'utf8', timeout: 20000 });
|
|
5415
|
+
const downgradeOk = r2.status === 0 && /gitignored/.test(r2.stdout || '');
|
|
5416
|
+
// ③ .env.bad + gitignore=.env.* → 명시 glob 보호 → 강등 info(exit0). 적정설정 프로젝트 FP 0
|
|
5417
|
+
const d3 = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-envglob-'));
|
|
5418
|
+
fs.writeFileSync(path.join(d3, '.gitignore'), '.env.*\n');
|
|
5419
|
+
fs.writeFileSync(path.join(d3, '.env.bad'), key);
|
|
5420
|
+
const r3 = cp.spawnSync(process.execPath, [CLI, 'scan', 'secrets', d3], { encoding: 'utf8', timeout: 20000 });
|
|
5421
|
+
const globOk = r3.status === 0 && /gitignored/.test(r3.stdout || '');
|
|
5422
|
+
[d1, d2, d3].forEach(d => fs.rmSync(d, { recursive: true, force: true }));
|
|
5423
|
+
ok = flaggedOk && downgradeOk && globOk;
|
|
5424
|
+
} catch {}
|
|
5425
|
+
console.log(ok ? '✓ B(1.9.386) 5th외부평가: secret scan env-family 포함 + gitignore git-일치(.env↛.env.bad 커밋대상) (UR-0087)' : '✗ secret scan env-family/gitignore 실패');
|
|
5426
|
+
if (!ok) failed++;
|
|
5427
|
+
}
|
|
5428
|
+
|
|
5429
|
+
// 1.9.387 회귀 (5번째 외부평가 일관성/UR-0088): incident/runs list 빈 케이스도 --json 구조화 {total:0,items:[]} + 사람용 보존
|
|
5430
|
+
total++;
|
|
5431
|
+
{
|
|
5432
|
+
let ok = false;
|
|
5433
|
+
try {
|
|
5434
|
+
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-listjson-'));
|
|
5435
|
+
cp.spawnSync(process.execPath, [CLI, 'init', d, '--yes', '--language', 'ko'], { encoding: 'utf8', timeout: 30000 });
|
|
5436
|
+
const ri = cp.spawnSync(process.execPath, [CLI, 'incident', 'list', '--path', d, '--json'], { encoding: 'utf8', timeout: 15000 });
|
|
5437
|
+
const ij = JSON.parse(ri.stdout);
|
|
5438
|
+
const rr = cp.spawnSync(process.execPath, [CLI, 'runs', 'list', '--path', d, '--json'], { encoding: 'utf8', timeout: 15000 });
|
|
5439
|
+
const rj = JSON.parse(rr.stdout);
|
|
5440
|
+
const jsonOk = ij.total === 0 && Array.isArray(ij.items) && ij.items.length === 0 && rj.total === 0 && Array.isArray(rj.items) && rj.items.length === 0;
|
|
5441
|
+
// 사람용 보존(--json 없이 → 텍스트, JSON 아님)
|
|
5442
|
+
const rih = cp.spawnSync(process.execPath, [CLI, 'incident', 'list', '--path', d], { encoding: 'utf8', timeout: 15000 });
|
|
5443
|
+
const humanOk = /incidents 없음/.test(rih.stdout || '') && !/^\s*\{/.test(rih.stdout || '');
|
|
5444
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
5445
|
+
ok = jsonOk && humanOk;
|
|
5446
|
+
} catch {}
|
|
5447
|
+
console.log(ok ? '✓ B(1.9.387) 5th외부평가 일관성: incident/runs list 빈 케이스 --json 구조화 + 사람용 보존 (UR-0088)' : '✗ list 빈 케이스 --json 실패');
|
|
5448
|
+
if (!ok) failed++;
|
|
5449
|
+
}
|
|
5450
|
+
|
|
5398
5451
|
console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
|
|
5399
5452
|
if (failed > 0) process.exit(1);
|