@datadog/datadog-ci-plugin-sarif 5.13.0 → 5.14.0

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/dist/bundle.js CHANGED
@@ -5909,7 +5909,7 @@ var require_src$9 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5909
5909
  var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5910
5910
  module.exports = {
5911
5911
  "name": "@datadog/datadog-ci-base",
5912
- "version": "5.13.0",
5912
+ "version": "5.14.0",
5913
5913
  "description": "Base package for Datadog CI",
5914
5914
  "license": "Apache-2.0",
5915
5915
  "keywords": ["datadog", "datadog-ci"],
@@ -5939,6 +5939,10 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5939
5939
  "development": "./src/constants.ts",
5940
5940
  "default": "./dist/constants.js"
5941
5941
  },
5942
+ "./helpers/request/*": {
5943
+ "development": "./src/helpers/request/*.ts",
5944
+ "default": "./dist/helpers/request/*.js"
5945
+ },
5942
5946
  "./helpers/*": {
5943
5947
  "development": "./src/helpers/*.ts",
5944
5948
  "default": "./dist/helpers/*.js"
@@ -7072,7 +7076,6 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
7072
7076
  ]);
7073
7077
  console.log();
7074
7078
  patchModulePaths(nodeModulesPath);
7075
- printPluginVersion(pluginPackage);
7076
7079
  });
7077
7080
  const handlePluginAutoInstall = (scope) => __awaiter(void 0, void 0, void 0, function* () {
7078
7081
  if (!!process.env["DISABLE_PLUGIN_AUTO_INSTALL"]) {
@@ -43740,177 +43743,6 @@ var require_dist$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
43740
43743
  exports.ProxyAgent = ProxyAgent;
43741
43744
  }));
43742
43745
  //#endregion
43743
- //#region ../../node_modules/ansi-escapes/index.js
43744
- var require_ansi_escapes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43745
- const ansiEscapes = module.exports;
43746
- module.exports.default = ansiEscapes;
43747
- const ESC = "\x1B[";
43748
- const OSC = "\x1B]";
43749
- const BEL = "\x07";
43750
- const SEP = ";";
43751
- const isTerminalApp = process.env.TERM_PROGRAM === "Apple_Terminal";
43752
- ansiEscapes.cursorTo = (x, y) => {
43753
- if (typeof x !== "number") throw new TypeError("The `x` argument is required");
43754
- if (typeof y !== "number") return ESC + (x + 1) + "G";
43755
- return ESC + (y + 1) + ";" + (x + 1) + "H";
43756
- };
43757
- ansiEscapes.cursorMove = (x, y) => {
43758
- if (typeof x !== "number") throw new TypeError("The `x` argument is required");
43759
- let ret = "";
43760
- if (x < 0) ret += ESC + -x + "D";
43761
- else if (x > 0) ret += ESC + x + "C";
43762
- if (y < 0) ret += ESC + -y + "A";
43763
- else if (y > 0) ret += ESC + y + "B";
43764
- return ret;
43765
- };
43766
- ansiEscapes.cursorUp = (count = 1) => ESC + count + "A";
43767
- ansiEscapes.cursorDown = (count = 1) => ESC + count + "B";
43768
- ansiEscapes.cursorForward = (count = 1) => ESC + count + "C";
43769
- ansiEscapes.cursorBackward = (count = 1) => ESC + count + "D";
43770
- ansiEscapes.cursorLeft = ESC + "G";
43771
- ansiEscapes.cursorSavePosition = isTerminalApp ? "\x1B7" : ESC + "s";
43772
- ansiEscapes.cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC + "u";
43773
- ansiEscapes.cursorGetPosition = ESC + "6n";
43774
- ansiEscapes.cursorNextLine = ESC + "E";
43775
- ansiEscapes.cursorPrevLine = ESC + "F";
43776
- ansiEscapes.cursorHide = ESC + "?25l";
43777
- ansiEscapes.cursorShow = ESC + "?25h";
43778
- ansiEscapes.eraseLines = (count) => {
43779
- let clear = "";
43780
- for (let i = 0; i < count; i++) clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : "");
43781
- if (count) clear += ansiEscapes.cursorLeft;
43782
- return clear;
43783
- };
43784
- ansiEscapes.eraseEndLine = ESC + "K";
43785
- ansiEscapes.eraseStartLine = ESC + "1K";
43786
- ansiEscapes.eraseLine = ESC + "2K";
43787
- ansiEscapes.eraseDown = ESC + "J";
43788
- ansiEscapes.eraseUp = ESC + "1J";
43789
- ansiEscapes.eraseScreen = ESC + "2J";
43790
- ansiEscapes.scrollUp = ESC + "S";
43791
- ansiEscapes.scrollDown = ESC + "T";
43792
- ansiEscapes.clearScreen = "\x1Bc";
43793
- ansiEscapes.clearTerminal = process.platform === "win32" ? `${ansiEscapes.eraseScreen}${ESC}0f` : `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
43794
- ansiEscapes.beep = BEL;
43795
- ansiEscapes.link = (text, url) => {
43796
- return [
43797
- OSC,
43798
- "8",
43799
- SEP,
43800
- SEP,
43801
- url,
43802
- BEL,
43803
- text,
43804
- OSC,
43805
- "8",
43806
- SEP,
43807
- SEP,
43808
- BEL
43809
- ].join("");
43810
- };
43811
- ansiEscapes.image = (buffer, options = {}) => {
43812
- let ret = `${OSC}1337;File=inline=1`;
43813
- if (options.width) ret += `;width=${options.width}`;
43814
- if (options.height) ret += `;height=${options.height}`;
43815
- if (options.preserveAspectRatio === false) ret += ";preserveAspectRatio=0";
43816
- return ret + ":" + buffer.toString("base64") + BEL;
43817
- };
43818
- ansiEscapes.iTerm = {
43819
- setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
43820
- annotation: (message, options = {}) => {
43821
- let ret = `${OSC}1337;`;
43822
- const hasX = typeof options.x !== "undefined";
43823
- const hasY = typeof options.y !== "undefined";
43824
- if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== "undefined")) throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");
43825
- message = message.replace(/\|/g, "");
43826
- ret += options.isHidden ? "AddHiddenAnnotation=" : "AddAnnotation=";
43827
- if (options.length > 0) ret += (hasX ? [
43828
- message,
43829
- options.length,
43830
- options.x,
43831
- options.y
43832
- ] : [options.length, message]).join("|");
43833
- else ret += message;
43834
- return ret + BEL;
43835
- }
43836
- };
43837
- }));
43838
- //#endregion
43839
- //#region ../../node_modules/supports-hyperlinks/index.js
43840
- var require_supports_hyperlinks = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43841
- const supportsColor = require_supports_color();
43842
- const hasFlag = require_has_flag();
43843
- function parseVersion(versionString) {
43844
- if (/^\d{3,4}$/.test(versionString)) {
43845
- const m = /(\d{1,2})(\d{2})/.exec(versionString);
43846
- return {
43847
- major: 0,
43848
- minor: parseInt(m[1], 10),
43849
- patch: parseInt(m[2], 10)
43850
- };
43851
- }
43852
- const versions = (versionString || "").split(".").map((n) => parseInt(n, 10));
43853
- return {
43854
- major: versions[0],
43855
- minor: versions[1],
43856
- patch: versions[2]
43857
- };
43858
- }
43859
- function supportsHyperlink(stream) {
43860
- const { env } = process;
43861
- if ("FORCE_HYPERLINK" in env) return !(env.FORCE_HYPERLINK.length > 0 && parseInt(env.FORCE_HYPERLINK, 10) === 0);
43862
- if (hasFlag("no-hyperlink") || hasFlag("no-hyperlinks") || hasFlag("hyperlink=false") || hasFlag("hyperlink=never")) return false;
43863
- if (hasFlag("hyperlink=true") || hasFlag("hyperlink=always")) return true;
43864
- if ("NETLIFY" in env) return true;
43865
- if (!supportsColor.supportsColor(stream)) return false;
43866
- if (stream && !stream.isTTY) return false;
43867
- if (process.platform === "win32") return false;
43868
- if ("CI" in env) return false;
43869
- if ("TEAMCITY_VERSION" in env) return false;
43870
- if ("TERM_PROGRAM" in env) {
43871
- const version = parseVersion(env.TERM_PROGRAM_VERSION);
43872
- switch (env.TERM_PROGRAM) {
43873
- case "iTerm.app":
43874
- if (version.major === 3) return version.minor >= 1;
43875
- return version.major > 3;
43876
- case "WezTerm": return version.major >= 20200620;
43877
- case "vscode": return version.major > 1 || version.major === 1 && version.minor >= 72;
43878
- }
43879
- }
43880
- if ("VTE_VERSION" in env) {
43881
- if (env.VTE_VERSION === "0.50.0") return false;
43882
- const version = parseVersion(env.VTE_VERSION);
43883
- return version.major > 0 || version.minor >= 50;
43884
- }
43885
- return false;
43886
- }
43887
- module.exports = {
43888
- supportsHyperlink,
43889
- stdout: supportsHyperlink(process.stdout),
43890
- stderr: supportsHyperlink(process.stderr)
43891
- };
43892
- }));
43893
- //#endregion
43894
- //#region ../../node_modules/terminal-link/index.js
43895
- var require_terminal_link = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43896
- const ansiEscapes = require_ansi_escapes();
43897
- const supportsHyperlinks = require_supports_hyperlinks();
43898
- const terminalLink = (text, url, { target = "stdout", ...options } = {}) => {
43899
- if (!supportsHyperlinks[target]) {
43900
- if (options.fallback === false) return text;
43901
- return typeof options.fallback === "function" ? options.fallback(text, url) : `${text} (\u200B${url}\u200B)`;
43902
- }
43903
- return ansiEscapes.link(text, url);
43904
- };
43905
- module.exports = (text, url, options = {}) => terminalLink(text, url, options);
43906
- module.exports.stderr = (text, url, options = {}) => terminalLink(text, url, {
43907
- target: "stderr",
43908
- ...options
43909
- });
43910
- module.exports.isSupported = supportsHyperlinks.stdout;
43911
- module.exports.stderr.isSupported = supportsHyperlinks.stderr;
43912
- }));
43913
- //#endregion
43914
43746
  //#region ../../node_modules/undici/lib/core/symbols.js
43915
43747
  var require_symbols = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43916
43748
  module.exports = {
@@ -65481,10 +65313,10 @@ var require_request = /* @__PURE__ */ __commonJSMin(((exports) => {
65481
65313
  throw requestError;
65482
65314
  }
65483
65315
  const responseHeaders = parseResponseHeaders(response.headers);
65484
- const contentType = (_h = responseHeaders["content-type"]) !== null && _h !== void 0 ? _h : "";
65316
+ const mediaType = ((_h = responseHeaders["content-type"]) !== null && _h !== void 0 ? _h : "").split(";")[0].trim();
65485
65317
  const rawBody = yield response.text();
65486
65318
  let data = rawBody;
65487
- if (contentType.includes("application/json") && rawBody.length > 0) try {
65319
+ if (rawBody.length > 0 && (mediaType === "application/json" || mediaType === "application/vnd.api+json")) try {
65488
65320
  data = JSON.parse(rawBody);
65489
65321
  } catch (_j) {}
65490
65322
  if (!response.ok) throw new RequestError(`Request failed with status code ${response.status}`, config, {
@@ -65536,20 +65368,15 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
65536
65368
  return mod && mod.__esModule ? mod : { "default": mod };
65537
65369
  };
65538
65370
  Object.defineProperty(exports, "__esModule", { value: true });
65539
- exports.isFile = exports.getGitHubEventPayload = exports.execute = exports.maskString = exports.formatBytes = exports.timedExecAsync = exports.filterAndFormatGithubRemote = exports.filterSensitiveInfoFromRepository = exports.performSubCommand = exports.pluralize = exports.normalizeRef = exports.recursivelyRemoveUndefinedValues = exports.removeUndefinedValues = exports.removeEmptyValues = exports.buildPath = exports.getApiHostForSite = exports.getProxyAgent = exports.getRequestBuilder = exports.getProxyUrl = exports.resolveConfigFromFile = exports.resolveConfigFromFileAndEnvironment = exports.getConfig = exports.pick = exports.makeTerminalLink = exports.DEFAULT_CONFIG_PATHS = void 0;
65371
+ exports.isFile = exports.getGitHubEventPayload = exports.execute = exports.maskString = exports.formatBytes = exports.timedExecAsync = exports.filterAndFormatGithubRemote = exports.filterSensitiveInfoFromRepository = exports.performSubCommand = exports.pluralize = exports.normalizeRef = exports.recursivelyRemoveUndefinedValues = exports.removeUndefinedValues = exports.removeEmptyValues = exports.buildPath = exports.getApiHostForSite = exports.getProxyAgent = exports.getRequestBuilder = exports.getProxyUrl = exports.resolveConfigFromFile = exports.resolveConfigFromFileAndEnvironment = exports.getConfig = exports.pick = exports.DEFAULT_CONFIG_PATHS = void 0;
65540
65372
  const child_process_1 = require("child_process");
65541
65373
  const fs_1$3 = require("fs");
65542
65374
  const util_1 = require("util");
65543
65375
  const clipanion_1 = require_advanced();
65544
65376
  const deep_extend_1 = __importDefault(require_deep_extend());
65545
65377
  const proxy_agent_1 = require_dist$3();
65546
- const terminal_link_1 = __importDefault(require_terminal_link());
65547
65378
  const request_1 = require_request();
65548
65379
  exports.DEFAULT_CONFIG_PATHS = ["datadog-ci.json"];
65549
- const makeTerminalLink = (url) => {
65550
- return ((strings) => (0, terminal_link_1.default)(strings[0], url));
65551
- };
65552
- exports.makeTerminalLink = makeTerminalLink;
65553
65380
  const pick = (base, keys) => {
65554
65381
  const definedKeys = keys.filter((key) => !!base[key]);
65555
65382
  const pickedObject = {};
@@ -65821,10 +65648,11 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
65821
65648
  return mod && mod.__esModule ? mod : { "default": mod };
65822
65649
  };
65823
65650
  Object.defineProperty(exports, "__esModule", { value: true });
65824
- exports.getGithubJobIDFromLogs = exports.getGithubStepInfoFromLogs = exports.enrichCIEnvFromGithubLogs = exports.getGithubJobNameFromLogs = exports.isGithubWindowsRunner = exports.shouldGetGithubJobID = exports.shouldGetGithubJobDisplayName = exports.isInteractive = exports.getCIProvider = exports.isCI = exports.getCIEnv = exports.getCIMetadata = exports.getCISpanTags = exports.githubWellKnownDiagnosticDirsWin = exports.githubWellKnownDiagnosticDirsUnix = exports.validateLevel = exports.LEVEL_TO_NUMBER = exports.VALID_LEVELS = exports.CI_LEVELS = exports.envDDGithubStepIndex = exports.envDDGithubJobName = exports.CI_ENGINES = void 0;
65651
+ exports.getGithubJobIDFromLogs = exports.getGithubStepInfoFromLogs = exports.enrichCIEnvFromGithubLogs = exports.getGithubJobNameFromLogs = exports.isGithubWindowsRunner = exports.shouldGetGithubJobID = exports.shouldGetGithubJobDisplayName = exports.isInteractive = exports.getCIProvider = exports.isCI = exports.getCIEnv = exports.getCIMetadata = exports.getCISpanTags = exports.githubWellKnownDiagnosticDirPatternsWin = exports.githubWellKnownDiagnosticDirPatternsUnix = exports.githubWellKnownDiagnosticDirsWin = exports.githubWellKnownDiagnosticDirsUnix = exports.validateLevel = exports.LEVEL_TO_NUMBER = exports.VALID_LEVELS = exports.CI_LEVELS = exports.envDDGithubStepIndex = exports.envDDGithubJobName = exports.CI_ENGINES = void 0;
65825
65652
  const fs_1$2 = __importDefault(require("fs"));
65826
65653
  const chalk_1 = __importDefault(require_source());
65827
65654
  const upath_1 = __importDefault(require_upath());
65655
+ const glob_1 = require_glob();
65828
65656
  const tags_1 = require_tags();
65829
65657
  const user_provided_git_1 = require_user_provided_git();
65830
65658
  const utils_1 = require_utils$1();
@@ -65878,12 +65706,10 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
65878
65706
  if (level === exports.CI_LEVELS.STEP && provider !== exports.CI_ENGINES.GITHUB) return `Level '${exports.CI_LEVELS.STEP}' is only supported for provider [${exports.CI_ENGINES.GITHUB}]`;
65879
65707
  };
65880
65708
  exports.validateLevel = validateLevel;
65881
- exports.githubWellKnownDiagnosticDirsUnix = [
65882
- "/home/runner/actions-runner/cached/_diag",
65883
- "/home/runner/actions-runner/_diag",
65884
- "/opt/actions-runner/_diag"
65885
- ];
65886
- exports.githubWellKnownDiagnosticDirsWin = ["C:/actions-runner/cached/_diag", "C:/actions-runner/_diag"];
65709
+ exports.githubWellKnownDiagnosticDirsUnix = ["/home/runner/actions-runner/_diag", "/opt/actions-runner/_diag"];
65710
+ exports.githubWellKnownDiagnosticDirsWin = ["C:/actions-runner/_diag"];
65711
+ exports.githubWellKnownDiagnosticDirPatternsUnix = ["/home/runner/actions-runner/*/_diag", "/home/runner/actions-runner/*/*/_diag"];
65712
+ exports.githubWellKnownDiagnosticDirPatternsWin = ["C:/actions-runner/*/_diag", "C:/actions-runner/*/*/_diag"];
65887
65713
  const githubJobDisplayNameRegex = /"jobDisplayName":\s*"((?:[^"\\]|\\.)*)"/;
65888
65714
  const githubJodIDRegex = /"job":\s*{[\s\S]*?"v"\s*:\s*(\d+)(?:\.0)?/;
65889
65715
  /**
@@ -65914,13 +65740,27 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
65914
65740
  const runnerTemp = process.env.RUNNER_TEMP;
65915
65741
  if (runnerTemp) {
65916
65742
  const runnerRoot = upath_1.default.resolve(runnerTemp, "..", "..");
65917
- dirs.push(upath_1.default.join(runnerRoot, "cached", "_diag"));
65743
+ dirs.push(`${runnerRoot}/*/_diag`);
65744
+ dirs.push(`${runnerRoot}/*/*/_diag`);
65918
65745
  dirs.push(upath_1.default.join(runnerRoot, "_diag"));
65919
- dirs.push(upath_1.default.join(runnerRoot, "actions-runner", "cached", "_diag"));
65746
+ dirs.push(`${runnerRoot}/actions-runner/*/_diag`);
65747
+ dirs.push(`${runnerRoot}/actions-runner/*/*/_diag`);
65920
65748
  dirs.push(upath_1.default.join(runnerRoot, "actions-runner", "_diag"));
65921
65749
  }
65922
65750
  return uniq(dirs.filter(Boolean));
65923
65751
  };
65752
+ /**
65753
+ * Expands a mixed list of literal directories and glob patterns into concrete
65754
+ * directories. Literals pass through unchanged (existence is checked later).
65755
+ */
65756
+ const expandDiagnosticDirCandidates = (candidates) => {
65757
+ const expanded = [];
65758
+ for (const candidate of candidates) if ((0, glob_1.hasMagic)(candidate)) try {
65759
+ expanded.push(...(0, glob_1.globSync)(candidate));
65760
+ } catch (_a) {}
65761
+ else expanded.push(candidate);
65762
+ return uniq(expanded);
65763
+ };
65924
65764
  const parseEmailAndName = (emailAndName) => {
65925
65765
  if (!emailAndName) return {
65926
65766
  name: "",
@@ -66512,8 +66352,16 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
66512
66352
  const getGithubWorkerLogFiles = (context) => {
66513
66353
  let foundDiagDir = "";
66514
66354
  let workerLogFiles = [];
66515
- let wellKnownDirs = uniq([...getGithubDiagnosticDirsFromEnv(), ...exports.githubWellKnownDiagnosticDirsUnix]);
66516
- if ((0, exports.isGithubWindowsRunner)()) wellKnownDirs = uniq([...getGithubDiagnosticDirsFromEnv(), ...exports.githubWellKnownDiagnosticDirsWin]);
66355
+ let wellKnownDirs = expandDiagnosticDirCandidates([
66356
+ ...getGithubDiagnosticDirsFromEnv(),
66357
+ ...exports.githubWellKnownDiagnosticDirPatternsUnix,
66358
+ ...exports.githubWellKnownDiagnosticDirsUnix
66359
+ ]);
66360
+ if ((0, exports.isGithubWindowsRunner)()) wellKnownDirs = expandDiagnosticDirCandidates([
66361
+ ...getGithubDiagnosticDirsFromEnv(),
66362
+ ...exports.githubWellKnownDiagnosticDirPatternsWin,
66363
+ ...exports.githubWellKnownDiagnosticDirsWin
66364
+ ]);
66517
66365
  for (const currentDir of wellKnownDirs) try {
66518
66366
  const potentialLogs = fs_1$2.default.readdirSync(currentDir, { withFileTypes: true }).filter((file) => file.isFile() && file.name.startsWith("Worker_") && file.name.endsWith(".log")).map((file) => file.name);
66519
66367
  if (potentialLogs.length > 0) {
@@ -66536,22 +66384,43 @@ var require_ci = /* @__PURE__ */ __commonJSMin(((exports) => {
66536
66384
  return [foundDiagDir, workerLogFiles];
66537
66385
  };
66538
66386
  /**
66539
- * Narrows the list of Worker log files to check by using ACTIONS_ORCHESTRATION_ID
66540
- * to identify the correct log for the current job on non-ephemeral runners.
66387
+ * Narrows the list of Worker log files to the one belonging to the current job.
66388
+ *
66389
+ * Worker log filenames contain a timestamp (Worker_YYYYMMDD-HHMMSS-utc.log), so
66390
+ * alphabetical order equals chronological order. Logs are always returned
66391
+ * newest-first so that the caller's iteration naturally encounters the current
66392
+ * job's log before any earlier ones — correct on both ephemeral and non-ephemeral
66393
+ * (multi) runners regardless of the strategy used.
66394
+ *
66395
+ * Primary strategy (runner >= v2.331.0, feature-flag gated):
66396
+ * ACTIONS_ORCHESTRATION_ID is set by the runner from the system.orchestrationId
66397
+ * variable in the job request message. That variable is serialized into the Worker
66398
+ * log as part of the job message JSON. planId is a GUID shared by all jobs in the
66399
+ * same workflow run, so the full orchestration ID is needed for a unique match:
66400
+ * Non-matrix job: <planId>.<yaml-job-key>.__default
66401
+ * Single-dimension matrix: <planId>.<yaml-job-key>.<matrix-value>
66402
+ * Multi-dimension matrix: <planId>.<yaml-job-key>.<val1>.<val2>[...]
66403
+ *
66404
+ * Fallback (runner < v2.331.0 or ACTIONS_ORCHESTRATION_ID absent/unmatched):
66405
+ * Return all logs newest-first. The caller iterates until it finds a jobDisplayName,
66406
+ * which on a single-job runner is immediate, and on a multi-runner is the current
66407
+ * job's (most recent) log.
66541
66408
  */
66542
66409
  const getTargetWorkerLogFiles = (context, foundDiagDir, workerLogFiles) => {
66410
+ const sortedNewestFirst = [...workerLogFiles].sort().reverse();
66543
66411
  const orchestrationId = process.env.ACTIONS_ORCHESTRATION_ID;
66544
- if (!orchestrationId) return workerLogFiles;
66545
- const planId = orchestrationId.split(".")[0];
66546
- for (const logFile of workerLogFiles) {
66547
- const filePath = upath_1.default.join(foundDiagDir, logFile);
66548
- if (fs_1$2.default.readFileSync(filePath, "utf-8").includes(`"planId": "${planId}"`)) {
66549
- context.stdout.write(`Found Worker log for planId ${planId}: ${logFile}\n`);
66550
- return [logFile];
66412
+ if (orchestrationId) {
66413
+ for (const logFile of sortedNewestFirst) {
66414
+ const filePath = upath_1.default.join(foundDiagDir, logFile);
66415
+ const content = fs_1$2.default.readFileSync(filePath, "utf-8");
66416
+ if (content.includes("\"system.orchestrationId\":") && content.includes(`"${orchestrationId}"`)) {
66417
+ context.stdout.write(`Found Worker log via system.orchestrationId for ${orchestrationId}: ${logFile}\n`);
66418
+ return [logFile];
66419
+ }
66551
66420
  }
66421
+ context.stderr.write(`${chalk_1.default.yellow.bold("[WARNING]")} Could not find Worker log via system.orchestrationId for ${orchestrationId}, checking all logs\n`);
66552
66422
  }
66553
- context.stderr.write(`${chalk_1.default.yellow.bold("[WARNING]")} Could not find Worker log for planId ${planId}, checking all logs\n`);
66554
- return workerLogFiles;
66423
+ return sortedNewestFirst;
66555
66424
  };
66556
66425
  const getGithubJobAttributeFromLogFiles = (context, foundDiagDir, workerLogFiles, jobAttributeRegex) => {
66557
66426
  const logsToCheck = getTargetWorkerLogFiles(context, foundDiagDir, workerLogFiles);
@@ -72438,6 +72307,66 @@ var require_tags = /* @__PURE__ */ __commonJSMin(((exports) => {
72438
72307
  };
72439
72308
  }));
72440
72309
  //#endregion
72310
+ //#region ../base/dist/helpers/request/datadog-route.js
72311
+ var require_datadog_route = /* @__PURE__ */ __commonJSMin(((exports) => {
72312
+ Object.defineProperty(exports, "__esModule", { value: true });
72313
+ exports.datadogRoute = exports.DATADOG_ROUTE_PATHS = void 0;
72314
+ /**
72315
+ * List of all Datadog API routes used by datadog-ci.
72316
+ *
72317
+ * Only those routes are accepted by {@link datadogRoute}.
72318
+ */
72319
+ exports.DATADOG_ROUTE_PATHS = [
72320
+ "/api/intake/ci/custom_spans",
72321
+ "/api/ui/support/serverless/flare",
72322
+ "/api/unstable/deployments/gates/evaluation",
72323
+ "/api/unstable/deployments/gates/evaluation/:evaluationId",
72324
+ "/api/v1/validate",
72325
+ "/api/v2/ci/deployments/correlate-image",
72326
+ "/api/v2/ci/deployments/correlate",
72327
+ "/api/v2/ci/pipeline/metrics",
72328
+ "/api/v2/ci/pipeline/tags",
72329
+ "/api/v2/cicodescan",
72330
+ "/api/v2/cicovreprt",
72331
+ "/api/v2/ciiac",
72332
+ "/api/v2/cireport",
72333
+ "/api/v2/dora/deployment",
72334
+ "/api/v2/git/repository/packfile",
72335
+ "/api/v2/git/repository/search_commits",
72336
+ "/api/v2/quality-gates/evaluate",
72337
+ "/api/v2/srcmap",
72338
+ "/api/v2/static-analysis-sca/dependencies",
72339
+ "/synthetics/ci/batch/:batchId",
72340
+ "/synthetics/ci/tunnel",
72341
+ "/synthetics/mobile/applications/:applicationId/multipart-presigned-urls",
72342
+ "/synthetics/mobile/applications/:applicationId/multipart-upload-complete",
72343
+ "/synthetics/mobile/applications/validation-job-status/:jobId",
72344
+ "/synthetics/settings",
72345
+ "/synthetics/tests/:testId",
72346
+ "/synthetics/tests/:testId/version_history/:version?only_check_existence=true",
72347
+ "/synthetics/tests/:testType/:testId",
72348
+ "/synthetics/tests/poll_results",
72349
+ "/synthetics/tests/search",
72350
+ "/synthetics/tests/trigger/ci",
72351
+ "/v1/input"
72352
+ ];
72353
+ /**
72354
+ * Format a Datadog API route with optional parameters.
72355
+ *
72356
+ * @example
72357
+ * ```ts
72358
+ * const route = datadogRoute('/api/v2/resources/:resourceId', {
72359
+ * resourceId: '123',
72360
+ * })
72361
+ * ```
72362
+ */
72363
+ const datadogRoute = (route, ...[params]) => {
72364
+ if (!params) return route;
72365
+ return route.replace(/:([A-Za-z0-9_]+)/g, (_, key) => encodeURIComponent(String(params[key])));
72366
+ };
72367
+ exports.datadogRoute = datadogRoute;
72368
+ }));
72369
+ //#endregion
72441
72370
  //#region ../../node_modules/delayed-stream/lib/delayed_stream.js
72442
72371
  var require_delayed_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
72443
72372
  var Stream$2 = require("stream").Stream;
@@ -81176,6 +81105,7 @@ var import_glob = require_glob();
81176
81105
  var import_retry = require_retry$1();
81177
81106
  var import_utils = require_utils$1();
81178
81107
  var import_tags = require_tags();
81108
+ var import_datadog_route = require_datadog_route();
81179
81109
  var import_form_data = /* @__PURE__ */ __toESM(require_form_data());
81180
81110
  var import_app = require_app();
81181
81111
  var import_source = /* @__PURE__ */ __toESM(require_source());
@@ -81263,7 +81193,7 @@ const uploadSarifReport = (request) => async (sarifReport, write) => {
81263
81193
  data: form,
81264
81194
  headers: form.getHeaders(),
81265
81195
  method: "POST",
81266
- url: "api/v2/cicodescan"
81196
+ url: (0, import_datadog_route.datadogRoute)("/api/v2/cicodescan")
81267
81197
  });
81268
81198
  };
81269
81199
  const apiConstructor = (baseIntakeUrl, apiKey) => {
@@ -150,19 +150,6 @@ ajv-formats/LICENSE:
150
150
  * SOFTWARE.
151
151
  */
152
152
 
153
- ansi-escapes/license:
154
- /*
155
- * MIT License
156
- *
157
- * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
158
- *
159
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
160
- *
161
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
162
- *
163
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
164
- */
165
-
166
153
  ansi-styles/license:
167
154
  /*
168
155
  * MIT License
@@ -1501,32 +1488,6 @@ supports-color/license:
1501
1488
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1502
1489
  */
1503
1490
 
1504
- supports-hyperlinks/license:
1505
- /*
1506
- * MIT License
1507
- *
1508
- * Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
1509
- *
1510
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1511
- *
1512
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1513
- *
1514
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1515
- */
1516
-
1517
- terminal-link/license:
1518
- /*
1519
- * MIT License
1520
- *
1521
- * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
1522
- *
1523
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1524
- *
1525
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1526
- *
1527
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1528
- */
1529
-
1530
1491
  tiny-async-pool/package.json:
1531
1492
  /*
1532
1493
  * License: MIT