Skip to content

Commit 2370082

Browse files
committed
test(loop): cover tagged permission keys
1 parent 8f242dd commit 2370082

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

loops/issue-dev-loop/scripts/lib/validation.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function conservativeYamlBlock(lines) {
9090
if (
9191
!mapping ||
9292
mapping.quoted ||
93+
mapping.key === 'permissions' ||
9394
/^[{[]/.test(mapping.value) ||
9495
/^[!&*]/.test(mapping.value)
9596
) {
@@ -109,7 +110,8 @@ function historicalWorkflowIsLowPrivilege(source) {
109110
(line) =>
110111
line.includes('\t') ||
111112
/^\s*<<\s*:/.test(line) ||
112-
/^\s*[?:]\s/.test(line),
113+
/^\s*[?:]\s/.test(line) ||
114+
/^(?:---|\.\.\.)\s*(?:#.*)?$/.test(line),
113115
)
114116
) {
115117
return false

loops/issue-dev-loop/tests/runtime.test.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5099,6 +5099,18 @@ test('historical active-run targets can validate without newer trusted runtime f
50995099
{permissions: write-all, runs-on: ubuntu-latest, steps: []}
51005100
`,
51015101
),
5102+
historicalWorkflow.replace(
5103+
' runs-on: ubuntu-latest\n',
5104+
' &permission_key permissions: write-all\n runs-on: ubuntu-latest\n',
5105+
),
5106+
historicalWorkflow.replace(
5107+
' runs-on: ubuntu-latest\n',
5108+
' !!str permissions: write-all\n runs-on: ubuntu-latest\n',
5109+
),
5110+
historicalWorkflow.replace(
5111+
' runs-on: ubuntu-latest\n',
5112+
' - permissions: write-all\n runs-on: ubuntu-latest\n',
5113+
),
51025114
]
51035115
for (const unsafeWorkflow of unsafeWorkflows) {
51045116
await writeFile(workflowPath, unsafeWorkflow, 'utf8')

0 commit comments

Comments
 (0)