@itenl/sec 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  一次配置、跨 Git 仓库使用的安全扫描 CLI。基于官方 `@openai/codex-security` 的独立封装,负责扫描范围、项目规范、风险门禁、私有或共享漏洞台账及修复复核。
4
4
 
5
- npm 包名为 `@itenl/sec`,首发版本 `0.1.0`,采用 MIT 许可证。支持 macOS / Linux,未声明 Windows 支持。扫描引擎固定为 `0.8.3`;本工具和模板的 MIT 许可不替代扫描引擎及所选模型服务各自的许可或使用条款。
5
+ npm 包名为 `@itenl/sec`,当前源码版本 `0.1.1`,采用 MIT 许可证。支持 macOS / Linux,未声明 Windows 支持。扫描引擎固定为 `0.8.3`;本工具和模板的 MIT 许可不替代扫描引擎及所选模型服务各自的许可或使用条款。
6
6
 
7
7
  ## 安装与快速开始
8
8
 
@@ -40,12 +40,26 @@ pnpm check:package
40
40
 
41
41
  ```sh
42
42
  pnpm pack
43
- npm install -g ./itenl-sec-0.1.0.tgz
43
+ npm install -g ./itenl-sec-0.1.1.tgz
44
44
  sec setup
45
45
  ```
46
46
 
47
47
  通过本地 tarball 安装不需要包已经发布,也不需要登录 npm。npm 的发布账号与 `sec setup` 中的模型服务认证是两套独立登录。
48
48
 
49
+ ## 从 0.1.0 升级
50
+
51
+ `0.1.0` 在传入项目规范或共享知识文档时,会提前把文档副本放进引擎输出目录,导致扫描在准备阶段报 `Scan output directory is not empty` 并以 `2` 退出。`0.1.1` 将这些输入副本移到私有状态目录的 `contexts/<执行标识>/`,扫描报告仍使用原来的 `runs/<执行标识>/`。
52
+
53
+ 安装已发布的修复版本后,直接重试原命令即可:
54
+
55
+ ```sh
56
+ npm install -g @itenl/sec@0.1.1
57
+ sec --version
58
+ sec branch
59
+ ```
60
+
61
+ 升级保留已有认证、用户配置、项目规范和漏洞台账,无需重新 setup 或 init。不要为解决这个错误删除状态目录或旧报告;该错误表示扫描未完成,不能视为零漏洞。`sec branch` 不支持直接传入引擎提示的 `--archive-existing` 参数。
62
+
49
63
  ## 一次 setup
50
64
 
51
65
  `sec setup` 可以在任意目录运行,不需要先进入项目。它会:
@@ -337,6 +351,7 @@ sec doctor
337
351
  - 每仓库比较目标配置:`~/.local/state/sec/repositories/<本机仓库路径哈希>/config.json`,可用 `sec config --local` 管理。
338
352
  - 未启用项目共享台账时的每仓库私有台账:`~/.local/state/sec/repositories/<本机仓库路径哈希>/ledger.json`。
339
353
  - 每次执行:同目录 `runs/<UTC 时间>-<模式>-<UUID>/`,包括 summary.md、原始报告、校验与复核资料。
354
+ - 项目规范与知识文档副本:同目录 `contexts/<执行标识>/`,与对应 `runs/<执行标识>/` 配对保留;引擎启动前的报告输出目录必须为空。
340
355
  - 状态根目录支持 `SEC_STATE_DIR`;否则使用 `XDG_STATE_HOME` 或默认值。
341
356
  - 仓库外临时快照结束时删除,目录回退使用用户缓存下的 `sec/tmp`。
342
357
 
@@ -635,7 +650,7 @@ npm publish --dry-run --ignore-scripts --access public --registry=https://regist
635
650
 
636
651
  ## 首次发布
637
652
 
638
- 首发包名为 `@itenl/sec`,版本为 `0.1.0`。发布者的 npm 账号必须拥有 `@itenl` scope 或相应组织的发布权限;GitHub 账号和仓库所有权不会自动授予 npm 权限。维护者应先检查 GitHub 仓库公开内容、完成自己的提交和推送,再将仓库公开。GitHub 仓库可见性与 npm 包可见性互相独立。
653
+ 包名为 `@itenl/sec`,本次版本为 `0.1.1`。发布者的 npm 账号必须拥有 `@itenl` scope 或相应组织的发布权限;GitHub 账号和仓库所有权不会自动授予 npm 权限。维护者应先检查 GitHub 仓库公开内容、完成自己的提交和推送,再将仓库公开。GitHub 仓库可见性与 npm 包可见性互相独立。
639
654
 
640
655
  在完成上面的发布检查及本地 tarball 安装验证后,由发布者在终端执行:
641
656
 
@@ -650,8 +665,8 @@ npm publish --access public --registry=https://registry.npmjs.org/
650
665
  发布完成后检查版本,并在新的终端或干净账户按快速开始验证:
651
666
 
652
667
  ```sh
653
- npm view @itenl/sec@0.1.0 version --registry=https://registry.npmjs.org/
654
- npm install -g @itenl/sec@0.1.0
668
+ npm view @itenl/sec@0.1.1 version --registry=https://registry.npmjs.org/
669
+ npm install -g @itenl/sec@0.1.1
655
670
  sec --version
656
671
  sec setup
657
672
  ```
package/lib/scan.mjs CHANGED
@@ -2,6 +2,8 @@ import { engineEnvironment, providerArguments, ensureEngine, invokeEngine } from
2
2
  import {
3
3
  readConfig,
4
4
  assertOutsideRepository,
5
+ privateDirectory,
6
+ repositoryDirectory,
5
7
  userDirectories,
6
8
  repositoryModelSettings,
7
9
  branchBaseRef
@@ -160,8 +162,12 @@ export async function main(mode = 'staged', args = []) {
160
162
  !project?.reportTemplate || absolute !== projectPath(root, project.reportTemplate)
161
163
  );
162
164
  const knowledgePaths = suppliedContext.map(({ absolute }, index) => {
163
- const copy = join(run.raw, 'context', String(index));
164
- mkdirSync(join(run.raw, 'context'), { recursive: true, mode: 0o700 });
165
+ // The engine requires an empty output directory at startup. Retain input
166
+ // copies separately so they cannot be mistaken for an existing scan.
167
+ const context = join(repositoryDirectory(root, environment), 'contexts', run.runId);
168
+ assertOutsideRepository(root, context);
169
+ privateDirectory(context);
170
+ const copy = join(context, String(index));
165
171
  // Preserve extensions for official document format detection.
166
172
  const destination = `${copy}-${absolute.split('/').at(-1)}`;
167
173
  cpSync(absolute, destination, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itenl/sec",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Security scanning CLI with project policies, shared findings and static fix verification",
5
5
  "type": "module",
6
6
  "bin": {