@diffci.com/diffci 0.3.24 → 0.3.26

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.
Files changed (42) hide show
  1. package/dist-client/src/client/cli.js +23 -1
  2. package/dist-client/src/client/enforce-policy.js +4 -0
  3. package/dist-client/src/client/gate.d.ts +3 -1
  4. package/dist-client/src/client/gate.js +1 -0
  5. package/dist-client/src/client/observe.js +14 -0
  6. package/dist-client/src/client/outcome-log.d.ts +80 -0
  7. package/dist-client/src/client/outcome-log.js +145 -0
  8. package/dist-client/src/client/report.d.ts +8 -0
  9. package/dist-client/src/client/verify.d.ts +3 -1
  10. package/dist-client/src/client/verify.js +1 -0
  11. package/dist-client/src/client/workflow-templates.d.ts +2 -2
  12. package/dist-client/src/client/workflow-templates.js +2 -2
  13. package/node_modules/@diffci.com/core/README.md +3 -0
  14. package/node_modules/@diffci.com/core/dist/git/ci-config-paths.d.ts +18 -0
  15. package/node_modules/@diffci.com/core/dist/git/ci-config-paths.js +136 -0
  16. package/node_modules/@diffci.com/core/dist/git/ci-config-paths.js.map +1 -0
  17. package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +2 -1
  18. package/node_modules/@diffci.com/core/dist/git/git-diff.js +17 -4
  19. package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
  20. package/node_modules/@diffci.com/core/dist/planner/path-baseline.js +2 -1
  21. package/node_modules/@diffci.com/core/dist/planner/path-baseline.js.map +1 -1
  22. package/node_modules/@diffci.com/core/dist/repo/file-references.d.ts +22 -2
  23. package/node_modules/@diffci.com/core/dist/repo/file-references.js +70 -10
  24. package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
  25. package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +24 -0
  26. package/node_modules/@diffci.com/core/dist/repo/impact.js +128 -6
  27. package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
  28. package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.d.ts +2 -2
  29. package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js +7 -5
  30. package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js.map +1 -1
  31. package/node_modules/@diffci.com/core/src/git/ci-config-paths.ts +131 -0
  32. package/node_modules/@diffci.com/core/src/git/git-diff.ts +18 -4
  33. package/node_modules/@diffci.com/core/src/planner/path-baseline.ts +2 -1
  34. package/node_modules/@diffci.com/core/src/repo/file-references.ts +74 -11
  35. package/node_modules/@diffci.com/core/src/repo/impact.ts +133 -7
  36. package/node_modules/@diffci.com/core/src/repo/workflow-test-steps.ts +8 -6
  37. package/node_modules/source-map-js/lib/quick-sort.js +10 -1
  38. package/node_modules/source-map-js/lib/source-map-consumer.js +51 -3
  39. package/node_modules/source-map-js/lib/source-map-generator.js +6 -4
  40. package/node_modules/source-map-js/lib/source-node.js +7 -0
  41. package/node_modules/source-map-js/package.json +1 -1
  42. package/package.json +2 -2
@@ -75,16 +75,18 @@ function commandRunsTests(text: string, scripts: Readonly<Record<string, string>
75
75
  * authoritative, not part of the suite DiffCI selects from. One dogfood repository's deploy workflow runs two such
76
76
  * checks, and counting them blocked every site HTML change in its replayed history.
77
77
  *
78
- * So the answer is true when a job step matching `names` is, or precedes, a step that runs the test
78
+ * So the answer is true when a job step `names` matches is, or precedes, a step that runs the test
79
79
  * command or a test runner, or an action not known to be test-free; when a reusable-workflow job or
80
80
  * job-level configuration names it in a job that runs tests; and whenever the YAML cannot be read.
81
81
  */
82
- export function workflowFeedsTests(workflowText: string, names: RegExp, scripts: Readonly<Record<string, string>> = {}): boolean {
82
+ export function workflowFeedsTests(workflowText: string, names: RegExp | ((text: string) => boolean), scripts: Readonly<Record<string, string>> = {}): boolean {
83
83
  let document: unknown;
84
84
  try { document = parse(workflowText); } catch { return true; }
85
85
  if (!document || typeof document !== "object") return true;
86
+ // A word-level matcher reads steps as JSON text, whose escapes (`\n`, `\"`) would join into words.
87
+ const named = typeof names === "function" ? (text: string) => names(text.replace(/\\[nrt]/g, " ").replace(/\\"/g, '"')) : (text: string) => names.test(text);
86
88
  const jobs = (document as { jobs?: unknown }).jobs;
87
- if (!jobs || typeof jobs !== "object") return names.test(workflowText);
89
+ if (!jobs || typeof jobs !== "object") return named(workflowText);
88
90
  const testStep = (step: unknown): boolean => {
89
91
  if (!step || typeof step !== "object") return true;
90
92
  const { uses, run } = step as { uses?: unknown; run?: unknown };
@@ -99,11 +101,11 @@ export function workflowFeedsTests(workflowText: string, names: RegExp, scripts:
99
101
  if (!job || typeof job !== "object") return true;
100
102
  if (jobDisabled(job)) continue;
101
103
  const { steps, uses, ...configuration } = job as { steps?: unknown; uses?: unknown };
102
- if (uses !== undefined) { if (names.test(JSON.stringify(job))) return true; continue; }
104
+ if (uses !== undefined) { if (named(JSON.stringify(job))) return true; continue; }
103
105
  if (!Array.isArray(steps)) return true;
104
- const firstNaming = steps.findIndex((step) => names.test(JSON.stringify(step)));
106
+ const firstNaming = steps.findIndex((step) => named(JSON.stringify(step)));
105
107
  const jobRunsTests = steps.some(testStep);
106
- if (jobRunsTests && names.test(JSON.stringify(configuration))) return true;
108
+ if (jobRunsTests && named(JSON.stringify(configuration))) return true;
107
109
  if (firstNaming !== -1 && steps.slice(firstNaming).some(testStep)) return true;
108
110
  }
109
111
  return false;
@@ -112,6 +112,15 @@ function cloneSort(comparator) {
112
112
  return templateFn(comparator);
113
113
  }
114
114
 
115
+ let isEvalAllowed = (function () {
116
+ try {
117
+ new Function('return 0')();
118
+ return true;
119
+ } catch {
120
+ return false;
121
+ }
122
+ })();
123
+
115
124
  /**
116
125
  * Sort the given array in-place with the given comparator function.
117
126
  *
@@ -123,7 +132,7 @@ function cloneSort(comparator) {
123
132
 
124
133
  let sortCache = new WeakMap();
125
134
  exports.quickSort = function (ary, comparator, start = 0) {
126
- let doQuickSort = sortCache.get(comparator);
135
+ let doQuickSort = isEvalAllowed ? sortCache.get(comparator) : SortTemplate(comparator);
127
136
  if (doQuickSort === void 0) {
128
137
  doQuickSort = cloneSort(comparator);
129
138
  sortCache.set(comparator, doQuickSort);
@@ -11,6 +11,14 @@ var ArraySet = require('./array-set').ArraySet;
11
11
  var base64VLQ = require('./base64-vlq');
12
12
  var quickSort = require('./quick-sort').quickSort;
13
13
 
14
+ // Upper bound for a section's `offset.line` in an indexed source map. A flat
15
+ // map spends one ';' per generated line, so a tiny indexed map with a huge
16
+ // offset.line turns into a huge amount of work and memory once its mappings
17
+ // are copied into a SourceMapGenerator (CVE-2026-93749). Ten million lines is
18
+ // far beyond any real generated file. Columns are VLQ-encoded as deltas and
19
+ // don't amplify, so they only need to be valid integers.
20
+ var MAX_SECTION_OFFSET_LINE = 1e7;
21
+
14
22
  function SourceMapConsumer(aSourceMap, aSourceMapURL) {
15
23
  var sourceMap = aSourceMap;
16
24
  if (typeof aSourceMap === 'string') {
@@ -935,6 +943,7 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
935
943
  line: -1,
936
944
  column: 0
937
945
  };
946
+ var maxOffsetLine = 0;
938
947
  this._sections = sections.map(function (s) {
939
948
  if (s.url) {
940
949
  // The url field will require support for asynchronicity.
@@ -945,12 +954,32 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
945
954
  var offsetLine = util.getArg(offset, 'line');
946
955
  var offsetColumn = util.getArg(offset, 'column');
947
956
 
957
+ if (!isValidOffset(offsetLine) || !isValidOffset(offsetColumn)) {
958
+ throw new Error('Section offset line and column must be non-negative integers.');
959
+ }
960
+ if (offsetLine > MAX_SECTION_OFFSET_LINE) {
961
+ throw new Error('Section offset line must not exceed ' + MAX_SECTION_OFFSET_LINE + '.');
962
+ }
963
+
948
964
  if (offsetLine < lastOffset.line ||
949
965
  (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
950
966
  throw new Error('Section offsets must be ordered and non-overlapping.');
951
967
  }
952
968
  lastOffset = offset;
953
969
 
970
+ var consumer = new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL);
971
+
972
+ // Offsets of a nested indexed map add up with this one, so apply the
973
+ // bound to the total.
974
+ var totalOffsetLine = offsetLine + (consumer._maxOffsetLine || 0);
975
+ if (totalOffsetLine > MAX_SECTION_OFFSET_LINE) {
976
+ throw new Error('Section offset line must not exceed ' + MAX_SECTION_OFFSET_LINE +
977
+ ', including offsets of nested sections.');
978
+ }
979
+ if (totalOffsetLine > maxOffsetLine) {
980
+ maxOffsetLine = totalOffsetLine;
981
+ }
982
+
954
983
  return {
955
984
  generatedOffset: {
956
985
  // The offset fields are 0-based, but we use 1-based indices when
@@ -958,9 +987,24 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
958
987
  generatedLine: offsetLine + 1,
959
988
  generatedColumn: offsetColumn + 1
960
989
  },
961
- consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
990
+ consumer: consumer
962
991
  }
963
992
  });
993
+
994
+ // The largest offset.line of any section, including nested sections.
995
+ this._maxOffsetLine = maxOffsetLine;
996
+ }
997
+
998
+ /**
999
+ * Section offsets come from untrusted input and are used as line/column
1000
+ * numbers, so only accept non-negative safe integers (rejects NaN, Infinity,
1001
+ * strings, fractions, etc).
1002
+ */
1003
+ function isValidOffset(aValue) {
1004
+ return typeof aValue === 'number' &&
1005
+ aValue >= 0 &&
1006
+ aValue <= 9007199254740991 && // Number.MAX_SAFE_INTEGER
1007
+ Math.floor(aValue) === aValue;
964
1008
  }
965
1009
 
966
1010
  IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
@@ -978,8 +1022,12 @@ Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
978
1022
  get: function () {
979
1023
  var sources = [];
980
1024
  for (var i = 0; i < this._sections.length; i++) {
981
- for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
982
- sources.push(this._sections[i].consumer.sources[j]);
1025
+ // Read the getter once per section: for a nested indexed map it is
1026
+ // itself this getter, and re-reading it per item is exponential in the
1027
+ // nesting depth (CVE-2026-93749).
1028
+ var sectionSources = this._sections[i].consumer.sources;
1029
+ for (var j = 0; j < sectionSources.length; j++) {
1030
+ sources.push(sectionSources[j]);
983
1031
  }
984
1032
  }
985
1033
  return sources;
@@ -348,10 +348,12 @@ SourceMapGenerator.prototype._serializeMappings =
348
348
 
349
349
  if (mapping.generatedLine !== previousGeneratedLine) {
350
350
  previousGeneratedColumn = 0;
351
- while (mapping.generatedLine !== previousGeneratedLine) {
352
- next += ';';
353
- previousGeneratedLine++;
354
- }
351
+ // One ';' per skipped line. Build large gaps with a single flat
352
+ // string: appending ';' one by one creates a rope node per line, which
353
+ // can exhaust the heap for a big gap (CVE-2026-93749).
354
+ var lineDelta = mapping.generatedLine - previousGeneratedLine;
355
+ next += lineDelta === 1 ? ';' : ';'.repeat(lineDelta);
356
+ previousGeneratedLine = mapping.generatedLine;
355
357
  }
356
358
  else {
357
359
  if (i > 0) {
@@ -113,6 +113,13 @@ SourceNode.fromStringWithSourceMap =
113
113
  // to the SourceNode without any mapping.
114
114
  // Each line is added as separate string.
115
115
  while (lastGeneratedLine < mapping.generatedLine) {
116
+ if (remainingLinesIndex >= remainingLines.length) {
117
+ // The generated code is exhausted. Skip the rest instead of adding
118
+ // empty lines one by one: a mapping may point far past the end of
119
+ // the code (e.g. an indexed map section with a huge offset.line).
120
+ lastGeneratedLine = mapping.generatedLine;
121
+ break;
122
+ }
116
123
  node.add(shiftNextLine());
117
124
  lastGeneratedLine++;
118
125
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "source-map-js",
3
3
  "description": "Generates and consumes source maps",
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
5
5
  "homepage": "https://github.com/7rulnik/source-map-js",
6
6
  "author": "Valentin 7rulnik Semirulnik <v7rulnik@gmail.com>",
7
7
  "contributors": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diffci.com/diffci",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "Fail-closed, change-aware verification for AI coding agents with conservative affected-test selection",
5
5
  "keywords": [
6
6
  "ci",
@@ -66,7 +66,7 @@
66
66
  "test": "node scripts/run-tests.mjs"
67
67
  },
68
68
  "dependencies": {
69
- "@diffci.com/core": "git+https://github.com/DiffCI/core.git#5ffdd32b58c7eed44c3bc14fd6dbfc0e849bcf91",
69
+ "@diffci.com/core": "git+https://github.com/DiffCI/core.git#2fe58684ecd2621a7beb64952862acdb2def0503",
70
70
  "yaml": "^2.9.0"
71
71
  },
72
72
  "devDependencies": {