@vaultcompass/vault-guard-core 1.4.0 → 1.4.2

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.
@@ -26,6 +26,35 @@ function normalizeFilePath(file, cwd) {
26
26
  return file;
27
27
  return rel || '.';
28
28
  }
29
+ /** Matches a Windows drive-letter absolute path (`C:\...`, `C:/...`) or a UNC path (`\\server\share`). */
30
+ const WINDOWS_ABSOLUTE_PATH_RE = /^(?:[a-zA-Z]:[\\/]|\\\\)/;
31
+ function isWindowsStylePath(p) {
32
+ return WINDOWS_ABSOLUTE_PATH_RE.test(p);
33
+ }
34
+ /**
35
+ * SARIF `artifactLocation.uri` must be a relative-reference URI: forward
36
+ * slashes only, no leading `./`, no leading `/` (the GitHub Code Scanning
37
+ * SARIF spec requires this even when the scanner itself runs on Windows,
38
+ * where `path.relative` returns backslash-separated paths).
39
+ *
40
+ * Picks `path.win32` when either side of the comparison looks like a
41
+ * Windows-style path, so this is correct both when the process itself runs
42
+ * on Windows (native `path` is already `path.win32`) and when a
43
+ * Windows-style path is normalized on a POSIX host (tests, or a SARIF file
44
+ * produced elsewhere and re-normalized).
45
+ */
46
+ function toSarifArtifactUri(file, cwd) {
47
+ if (cwd === null)
48
+ return file.split('\\').join('/');
49
+ const base = cwd ?? process.cwd();
50
+ const impl = isWindowsStylePath(file) || isWindowsStylePath(base) ? path_1.default.win32 : path_1.default;
51
+ if (!impl.isAbsolute(file))
52
+ return file.split('\\').join('/');
53
+ const rel = impl.relative(base, file);
54
+ if (rel.startsWith('..') || impl.isAbsolute(rel))
55
+ return file.split('\\').join('/');
56
+ return (rel || '.').split('\\').join('/');
57
+ }
29
58
  function formatJson(results, opts = {}) {
30
59
  const fpCwd = opts.cwd === undefined ? process.cwd() : opts.cwd;
31
60
  const output = {
@@ -60,6 +89,7 @@ function formatJson(results, opts = {}) {
60
89
  }
61
90
  /** SARIF 2.1.0 — compatible with GitHub Code Scanning (upload-sarif action). */
62
91
  function formatSarif(results, opts = {}) {
92
+ const fpCwd = opts.cwd === undefined ? process.cwd() : opts.cwd;
63
93
  const rules = [
64
94
  ...new Set(results.flatMap(r => r.matches.map(m => m.type))),
65
95
  ].map(id => ({
@@ -82,7 +112,7 @@ function formatSarif(results, opts = {}) {
82
112
  locations: [
83
113
  {
84
114
  physicalLocation: {
85
- artifactLocation: { uri: normalizeFilePath(file, opts.cwd), uriBaseId: '%SRCROOT%' },
115
+ artifactLocation: { uri: toSarifArtifactUri(file, opts.cwd), uriBaseId: '%SRCROOT%' },
86
116
  region: {
87
117
  startLine: m.line,
88
118
  startColumn: m.column + 1,
@@ -91,6 +121,10 @@ function formatSarif(results, opts = {}) {
91
121
  },
92
122
  },
93
123
  ],
124
+ // Same fingerprint the JSON output emits per finding (positional: keyed
125
+ // on relative path + type + line + offset + matchLength). Lets GitHub
126
+ // Code Scanning track a finding's identity across runs.
127
+ partialFingerprints: { 'vault-guard/v1': (0, match_fingerprint_1.fingerprintForMatch)(fpCwd, file, m) },
94
128
  })));
95
129
  // Diagnostics are emitted as SARIF notifications (tool/driver/notifications)
96
130
  // so they appear in the GitHub Code Scanning UI as tool warnings rather than
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaultcompass/vault-guard-core",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Secret-scanning engine: vendor-anchored patterns, entropy gating, baselines, SARIF/JSON, hook helpers.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",