Skip to content

Commit f2e68df

Browse files
committed
Supporting immutable Actions too
1 parent 6f89aae commit f2e68df

1 file changed

Lines changed: 41 additions & 4 deletions

File tree

audit_workflow_runs_utils.js

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,68 @@ export function parseFromInputFile(actionsToAuditFilename) {
5959
}
6060

6161
// Regex to spot, e.g. Download action repository 'actions/checkout@v4' (SHA:11bd71901bbe5b1630ceea73d27597364c9af683)
62-
const actionRegex = /^Download action repository '(.+?)' \(SHA:(.+?)\)/;
62+
const mutableActionPrefix = "Download action repository '";
63+
const mutableActionRegex = /^Download action repository '([^']+?)' \(SHA:([^)]+?)\)/;
64+
const immutableActionPrefix = "##[group]Download immutable action package '";
65+
const immutableActionRegex = /^##\[group\]Download immutable action package '([^']+?)'/;
6366

6467
export function searchForActionsLines(logContent) {
6568
const logLines = logContent.split("\n");
6669
const actions = [];
6770
let foundActions = false;
71+
let inImmutableGroup = false;
72+
let immutableAction = {};
6873

6974
for (const line of logLines) {
7075
// separate the timestamp from the data
7176
const data = line.split(" ").slice(1).join(" ");
7277
if (data == undefined) {
7378
continue;
7479
}
75-
if (data.startsWith("Download action repository '")) {
80+
if (data.startsWith(mutableActionPrefix)) {
7681
foundActions = true;
77-
const match = actionRegex.exec(data);
82+
const match = mutableActionRegex.exec(data);
7883
if (match) {
7984
const action = match[1];
8085
const sha = match[2];
8186

8287
const [repo, version] = action.split("@");
8388
actions.push([repo, version, sha]);
8489
}
85-
// quit processing the log after the first line that is not an action, if we already found actions
90+
} else if (data.startsWith(immutableActionPrefix)) {
91+
foundActions = true;
92+
inImmutableGroup = true;
93+
const match = immutableActionRegex.exec(data);
94+
if (match) {
95+
const action = match[1];
96+
const tag = match[2];
97+
98+
immutableAction = {
99+
action: action,
100+
tag: tag,
101+
version: null,
102+
sha: null,
103+
digest: null,
104+
}
105+
}
106+
} else if (inImmutableGroup && data.startsWith("##[endgroup]")) {
107+
actions.push([immutableAction.action, ])
108+
inImmutableGroup = false;
109+
} else if (inImmutableGroup) {
110+
const versionMatch = data.match(/Version: ([a-zA-Z0-9._-]+)/);
111+
const shaMatch = data.match(/Source commit SHA: ([a-f0-9]{40,})/);
112+
const digestMatch = data.match(/Digest: sha256:[a-f0-9]{64}/);
113+
if (versionMatch) {
114+
immutableAction.version = versionMatch[1];
115+
}
116+
if (shaMatch) {
117+
immutableAction.sha = shaMatch[1];
118+
}
119+
if (digestMatch) {
120+
immutableAction.digest = digestMatch[0];
121+
}
86122
} else if (foundActions) {
123+
// quit processing the log after the first line that is not an action, if we already found actions
87124
break;
88125
}
89126
}

0 commit comments

Comments
 (0)