dsh-code-security 0.3.3 → 0.3.4

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.en.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # dsh-code-security
2
2
 
3
+ ## 0.3.4 update (2026-09-27)
4
+
5
+ Fixes scan output validation when no baseline exists. SARIF now uses workspace file URIs, relative locations and structured rule descriptions, including paths with spaces and Unicode.
6
+
7
+ Validation host: Harness 0.1.7-rc.2 built from official sources, retaining the local tool-scheduler fix. Build and automated checks pass; interactive coverage and external-service limits are recorded in this release round.
8
+
3
9
  ![npm](https://img.shields.io/npm/v/dsh-code-security) ![downloads](https://img.shields.io/npm/dm/dsh-code-security) ![license](https://img.shields.io/github/license/STARDUSTLC666/dsh-code-security) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-code-security?style=social)
4
10
 
5
11
  > Every agent code change passes a local security scan before delivery.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # dsh-code-security
2
2
 
3
+ ## 0.3.4 更新(2026-09-27)
4
+
5
+ 修复未设置基线时扫描结果被新版 Harness 拒绝的问题。SARIF 正确使用工作区文件 URI、相对路径和规则描述对象,支持空格与中文文件名。
6
+
7
+ 验证宿主:官方源码构建的 Harness 0.1.7-rc.2(保留本地工具调度器修复)。构建与自动测试通过;实际操作和外部服务限制见本轮验收记录。
8
+
3
9
  ![npm](https://img.shields.io/npm/v/dsh-code-security) ![downloads](https://img.shields.io/npm/dm/dsh-code-security) ![license](https://img.shields.io/github/license/STARDUSTLC666/dsh-code-security) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-code-security?style=social)
4
10
 
5
11
  > 让 agent 每次改完代码,先过一道本地安全扫描,修复完了才准交付。
package/lib/tools.js CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { writeFile } from 'node:fs/promises';
9
9
  import path from 'node:path';
10
+ import { pathToFileURL } from 'node:url';
10
11
  import { optionalString, requiredString } from './config.js';
11
12
  import { buildExtraTools } from './extra.js';
12
13
  import { runGitDiff, scanDiff } from './diff.js';
@@ -54,7 +55,7 @@ const scanSchema = {
54
55
  failOn: { type: 'string' }, durationMs: { type: 'integer' },
55
56
  newFindings: { type: 'array', items: findingSchema }, newCounts: countsSchema,
56
57
  acceptedFindings: { type: 'array', items: findingSchema },
57
- baseline: { type: 'object', additionalProperties: true },
58
+ baseline: { oneOf: [{ type: 'object', additionalProperties: true }, { type: 'null' }] },
58
59
  },
59
60
  additionalProperties: true,
60
61
  };
@@ -320,7 +321,7 @@ export function buildSecureTools(cfg, cwd, runner) {
320
321
  const state = await loadState(stateDir);
321
322
  if (state.last === null)
322
323
  throw new Error('尚无扫描结果,请先执行 secure_scan 或 secure_diff。');
323
- const text = format === 'sarif' ? buildSarif(state.last.findings, state.last.target) : buildMarkdown(state.last.findings, state.last.target);
324
+ const text = format === 'sarif' ? buildSarif(state.last.findings, cwd) : buildMarkdown(state.last.findings, state.last.target);
324
325
  if (target !== undefined)
325
326
  await writeFile(target, text, 'utf8');
326
327
  return { format, path: target ?? '', text, findingCount: state.last.findings.length };
@@ -362,15 +363,15 @@ function buildMarkdown(findings, target) {
362
363
  }
363
364
  return lines.join('\n') + '\n';
364
365
  }
365
- function buildSarif(findings, target) {
366
+ function buildSarif(findings, cwd) {
366
367
  const rules = new Map();
367
368
  const results = findings.map((finding, index) => {
368
- rules.set(finding.ruleId, { id: finding.ruleId, name: finding.title, shortDescription: finding.title });
369
+ rules.set(finding.ruleId, { id: finding.ruleId, name: finding.title, shortDescription: { text: finding.title } });
369
370
  return {
370
371
  ruleId: finding.ruleId,
371
372
  level: finding.severity === 'critical' || finding.severity === 'high' ? 'error' : finding.severity === 'medium' ? 'warning' : 'note',
372
373
  message: { text: finding.message },
373
- locations: [{ physicalLocation: { artifactLocation: { uri: finding.file.replace(/\\/g, '/') }, region: { startLine: finding.line } } }],
374
+ locations: [{ physicalLocation: { artifactLocation: { uri: finding.file.replace(/\\/g, '/').split('/').map(encodeURIComponent).join('/'), uriBaseId: 'ROOTPATH' }, region: { startLine: finding.line } } }],
374
375
  partialFingerprints: { primaryLocationLineHash: finding.id + ':' + String(index) },
375
376
  };
376
377
  });
@@ -379,7 +380,7 @@ function buildSarif(findings, target) {
379
380
  $schema: 'https://json.schemastore.org/sarif-2.1.0.json',
380
381
  runs: [{
381
382
  tool: { driver: { name: 'dsh-code-security', version: '0.1.0', informationUri: 'https://github.com/STARDUSTLC666/dsh-code-security', rules: [...rules.values()] } },
382
- originalUriBaseIds: { ROOTPATH: { uri: 'file:///' + target.replace(/\\/g, '/') } },
383
+ originalUriBaseIds: { ROOTPATH: { uri: pathToFileURL(path.resolve(cwd) + path.sep).href } },
383
384
  results,
384
385
  }],
385
386
  }, null, 2);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-code-security",
3
- "version": "0.3.3",
4
- "description": "DSH AI 代码安全审查插件:secure_scan/secure_diff/secure_fix_verify/secure_report/secure_export/secure_baseline/secure_deps/secure_policy_show/secure_policy_set 九工具,40+ 确定性规则、密钥熵检测、git diff/staged 审查、SARIF 导出、基线接受与 SBOM-lite,零运行时依赖。",
3
+ "version": "0.3.4",
4
+ "description": "DSH 代码安全审查插件:40+ 确定性规则与密钥熵检测,支持 git diff/staged 审查、SARIF 导出、基线接受与 SBOM-lite。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",