diff --git a/.github/workflow-pins/README.md b/.github/workflow-pins/README.md index 536673ef..cdbf318f 100644 --- a/.github/workflow-pins/README.md +++ b/.github/workflow-pins/README.md @@ -132,20 +132,44 @@ message, because neither BE-8130 remedy can fix operand order. A leading operand `||` falls *through* (`false`, `''`, `""`, `0`, `null`) still reaches the output and is judged normally. -Spellings this reader still does not recognize — a fallback containing a brace +**A spelling the reader cannot parse is REFUSED, not skipped (BE-8253).** The +reader is two-tier: a permissive tier asks whether the comment-stripped `ref:` +value mentions `steps..outputs.` at all, and the strict tier reads +every interpolation and every top-level `||` operand in it. When the first +counts more mentions than the second could account for, the site is reported — +the lint says it cannot judge this expression and names the spellings it can. +Unrecognized spellings include a fallback containing a brace (`|| format('refs/heads/{0}', 'main')`), a parenthesized operand (`(steps..outputs.) || 'main'`), a TRAILING `&&` -(`${{ steps..outputs. && 'main' }}`), and the FLOW spelling of a -fallback whose literal contains a comma (`with: {ref: "${{ -steps..outputs. || 'a,b' }}"}`, where the flow reader's `[^,}]` entry -boundary ends the match inside the quotes — the block form reads it) — match -nothing and record no site, exactly as every `||` spelling did before BE-8215. +(`${{ steps..outputs. && 'main' }}`), and — in the flow form only, +whose interpolation body still stops at a comma even though `BE-8253` made its +*entry* boundary interpolation-aware — a fallback whose literal contains one +(`with: {ref: "${{ steps..outputs. || 'a,b' }}"}`; the block form +reads this spelling fine). Each of those used to match nothing and record no +site, so the lint PASSED a workflow it had never read while failing the +identical one spelled bare; now the site is reported `'unparsed'` and refused. A *leading* `&&` is the opposite case, not this one: it MATCHES, nothing but an `||` chain clears the leading-operand check, and a site the lint has a claim on at all — one naming a resolver, or a dangling id — fails as `non-leading`, red CI rather than silence. Write the ref as a bare -`${{ steps..outputs. }}` under the exact `if:`, or as a plain -`|| ` fallback, and it is covered. +`${{ steps..outputs. }}` under the exact `if:`, or as that expression +with a trailing `|| ` fallback, and it is covered. The reader does not +evaluate `format()`, `&&` or parenthesized expressions on purpose: an unknown +spelling asks its author for a supported one rather than growing an expression +parser inside the lint. + +**Every operand is judged, and the strongest requirement wins (BE-8253).** A +`ref:` value can read more than one step output, and each one is a ref the +checkout can really resolve to — so each must independently pass (declared as +an earlier step, covered by a fail-closed resolver or the exact non-empty `if:`, +and reachable by operand order). A covered sibling excuses nothing. Two shapes +used to slip through on a single verdict per line: +`ref: "${{ steps.a.outputs.ref }}${{ steps.b.outputs.ref }}"`, where only the +LAST interpolation was judged even though both feed the value, and +`ref: ${{ steps.a.outputs.ref || steps.b.outputs.ref }}`, where the fallback +stretch swallowed `b`. A step output ahead of another operand does not make it +non-leading: an unresolved output is `''`, so `||` really can fall through to +what follows — and that leading output is judged in its own right. **The lint enforces that split, rather than trusting the prose.** The fallback answers *mutability*; the guard answers *emptiness*; a checkout using the diff --git a/.github/workflow-pins/check_workflow_pins.py b/.github/workflow-pins/check_workflow_pins.py index 3da17666..99b88457 100644 --- a/.github/workflow-pins/check_workflow_pins.py +++ b/.github/workflow-pins/check_workflow_pins.py @@ -179,33 +179,76 @@ def _bracket_body(name_alt): # carries what precedes the step output inside the interpolation so operand # order can be judged the same way there. # -# Those two widened stretches are bounded by `[^}]`, NOT the flow form's -# `[^,}]`: only the flow spelling needs a comma to end its entry, and carrying -# that bound into the block and continuation forms left a fallback containing a -# comma (`|| 'a,b'`) matching nothing at all — the same fail-open this change -# closes for the plain `|| ` spelling. `[^}]` still cannot cross a -# `}}`, so a match can never span two interpolations. The flow form keeps -# `[^,}]` throughout, exactly as `_REF_USE_FLOW_RE` bounds its own value, so a -# SIBLING entry carrying a step output cannot be misread as the ref. -def _steps_output_body(bound): - """The `${{ … steps..outputs. … }}` body, bounded by `bound`.""" - return ( - r"""\$\{\{(?P%s*?)""" - r"""(?:steps\.(?P[A-Za-z0-9_-]+)|steps\[\s*['"](?P[A-Za-z0-9_-]+)['"]\s*\])""" - r"""\.(?:outputs\.(?P[A-Za-z0-9_-]+)|outputs\[\s*['"](?P[A-Za-z0-9_-]+)['"]\s*\])""" - r"""\s*(?:\|\|%s*?)?\}\}""" - ) % (bound, bound) - - -_STEPS_OUTPUT_BODY = _steps_output_body(r"""[^}]""") -_STEPS_OUTPUT_FLOW_BODY = _steps_output_body(r"""[^,}]""") -_STEPS_OUTPUT_BLOCK_RE = re.compile(r"""^\s*(['"]?)ref\1\s*:.*%s""" % _STEPS_OUTPUT_BODY) -_STEPS_OUTPUT_FLOW_RE = re.compile( - r"""[{,]\s*(['"]?)ref\1\s*:[^,}]*%s""" % _STEPS_OUTPUT_FLOW_BODY +# …and the reader is TWO-TIER (BE-8253), because ONE regex per line can only +# give ONE verdict per line, while a `ref:` value can hold several step outputs +# — or a spelling this reader does not understand at all: +# +# LOOSE — does the comment-stripped `ref:` VALUE mention +# `steps..outputs.` anywhere, any number of times? +# STRICT — the patterns below, run over EVERY interpolation in that value and +# every top-level `||` operand inside each one. +# +# When LOOSE counts more mentions than STRICT accounted for, the value plainly +# reaches a step output this reader cannot judge, and the site is recorded +# `'unparsed'` so the lint REFUSES it out loud. Before the split it answered +# "no site" instead: `ref: ${{ steps.x.outputs.ref || format('refs/heads/{0}', +# 'main') }}` matched nothing (the `}` in `{0}` breaks the fallback stretch), +# recorded nothing, and PASSED — fail-open on exactly the runtime behavior this +# lint exists to close, and the identical workflow spelled bare failed. So did +# `(steps.x.outputs.ref) || 'main'` and `steps.x.outputs.ref && 'main'`. +# Teaching the strict reader to EVALUATE `format()` / `&&` / parenthesized +# operands is deliberately not the fix: an unknown spelling asks its author for +# a supported one rather than growing an expression parser in here. +# +# Both tiers read the bracket accessor too (BE-8146): `steps['']` and +# `outputs['']`, each independently of the other's spelling, alongside the +# dot form — a bracket-spelled output must count as a LOOSE mention and be +# readable by STRICT exactly like the dot form, never silently miscounted into +# `'unparsed'` or dropped as no mention at all. +# +# The strict stretches are bounded by `[^}]`, NOT the flow form's `[^,}]`: only +# the flow spelling needs a comma to end its entry, and carrying that bound +# into the block and continuation forms left a fallback containing a comma +# (`|| 'a,b'`) matching nothing at all — the same fail-open. `[^}]` still +# cannot cross a `}}`, so an interpolation match can never span two of them, +# and a body carrying a brace of its own is how shape 1 above reaches +# `'unparsed'` rather than being silently skipped. +_STEPS_OUTPUT_ID_RE = r"""(?:steps\.[A-Za-z0-9_-]+|steps\[\s*['"][A-Za-z0-9_-]+['"]\s*\])""" +_STEPS_OUTPUT_OUT_RE = r"""(?:outputs\.[A-Za-z0-9_-]+|outputs\[\s*['"][A-Za-z0-9_-]+['"]\s*\])""" +_LOOSE_STEPS_OUTPUT_RE = re.compile( + r"""%s\.%s""" % (_STEPS_OUTPUT_ID_RE, _STEPS_OUTPUT_OUT_RE) ) -_STEPS_OUTPUT_CONT_RE = re.compile( - r"""^\s*(?P['"]?)%s(?P=q)[^\S\n]*$""" % _STEPS_OUTPUT_BODY +# An operand that is NOTHING BUT a step output. `||` falls through an empty +# one, so unlike a truthy literal it does not decide the value for the operands +# behind it — see `_lead_reaches_output`. +_BARE_STEPS_OUTPUT_RE = re.compile( + r"""^%s\.%s$""" % (_STEPS_OUTPUT_ID_RE, _STEPS_OUTPUT_OUT_RE) ) +# The strict tier's unit: what the old single-match body required of the +# stretch AROUND the output, asked of one `||` operand at a time. `lead` keeps +# its meaning (what precedes the output, judged by `_lead_reaches_output`), and +# the `\s*$` anchor is what refuses the parenthesized and `&&` spellings — +# both carry something AFTER the output name that this reader cannot evaluate. +_STEPS_OUTPUT_OPERAND_RE = re.compile( + r"""^(?P.*?)""" + r"""(?:steps\.(?P[A-Za-z0-9_-]+)|steps\[\s*['"](?P[A-Za-z0-9_-]+)['"]\s*\])""" + r"""\.(?:outputs\.(?P[A-Za-z0-9_-]+)|outputs\[\s*['"](?P[A-Za-z0-9_-]+)['"]\s*\])""" + r"""\s*$""" +) + + +def _steps_interp_re(bound): + """`${{ … }}`, its body bounded by `bound` — one strict-tier unit.""" + return re.compile(r"""\$\{\{(?P%s*)\}\}""" % bound) + + +_STEPS_INTERP_RE = _steps_interp_re(r"""[^}]""") +_STEPS_INTERP_FLOW_RE = _steps_interp_re(r"""[^,}]""") +# Where a `ref:` VALUE begins, per spelling. The block form takes the rest of +# the line; a flow entry is delimited by `_flow_entry_value`; the continuation +# line under `ref: >-` / `ref: |` IS the value and carries no key at all. +_REF_KEY_VALUE_RE = re.compile(r"""^\s*(['"]?)ref\1\s*:(?P.*)$""") +_REF_FLOW_KEY_RE = re.compile(r"""[{,]\s*(['"]?)ref\1\s*:""") # The producing step's `id:`, read at the step's own key column. Quoted or bare # — both are valid Actions YAML — and `\S+` stops before a trailing comment on # its own, because YAML needs whitespace ahead of a `#` for it to open one. @@ -931,70 +974,91 @@ def is_ref_use(line, res=None): return bool(block_re.match(line) or flow_re.search(line)) -def _steps_output_match(code, cont=False): - """The `_STEPS_OUTPUT_*` match object for `code`, or None.""" - if cont: - return _STEPS_OUTPUT_CONT_RE.match(code) - match = _STEPS_OUTPUT_BLOCK_RE.match(code) - if match is None: - # The flow form `search`es mid-line, so its `[{,]` entry boundary can - # be met by a comma INSIDE a quoted sibling — planting a decoy `ref:` - # that resolves to a step no checkout consumes, while the real `ref:` - # further along the line is never examined. `_pins_to_job_workflow_sha` - # answers that by requiring its match to sit outside quotes; here the - # walk must also keep LOOKING past the decoy, because stopping at it - # drops the site out of coverage entirely rather than merely scoring - # it weaker. - for candidate in _STEPS_OUTPUT_FLOW_RE.finditer(code): - if _outside_quotes(code, candidate.start()): - return candidate - return match +def _flow_entry_value(code, start): + """The flow-mapping entry value beginning at `start`, up to its boundary. + + `${{ … }}` is ATOMIC here: a `,` or `}` INSIDE an interpolation belongs to + the expression (`|| 'a,b'`, `format('refs/heads/{0}', 'main')`), not to the + mapping, so the naive `[^,}]` bound cuts the value mid-expression and hides + the rest of it from BOTH tiers — which would read as "nothing to see" on + exactly the shapes BE-8253 exists to refuse. Outside an interpolation the + first `,` or `}` still ends the entry, so a SIBLING entry carrying a step + output cannot be misread as the ref. + """ + depth = 0 + i = start + while i < len(code): + if code.startswith("${{", i): + depth += 1 + i += 3 + continue + if depth and code.startswith("}}", i): + depth -= 1 + i += 2 + continue + if not depth and code[i] in ",}": + break + i += 1 + return code[start:i] -def steps_output_ref(line, cont=False): - """(step id, output name) when `line`'s `ref:` IS a step output, else None. +def _ref_values(code, cont=False): + """[(value, flow)] for every `ref:` value on the comment-stripped `code`. - Answers only "which step produced this ref" — never whether the checkout is - covered. `ref_checkouts` decides that, because the answer depends on which - steps the job has already walked past. `cont=True` judges a CONTINUATION - line instead: the bare expression under a `ref: >-` / `ref: |` key, which - carries no `ref:` of its own. + Empty when the line carries no `ref:` key at all — the answer for most + lines, since the walk asks this of every line in the job. - Comments are stripped first, for the same reason `_pins_to_job_workflow_sha` - strips them: prose merely naming a step output (`ref: main # was - ${{ steps.x.outputs.ref }}`) is not a checkout resolved from one. + The flow form yields one entry per `ref:` sitting OUTSIDE any quoted + scalar. A comma inside a quoted sibling meets the `[{,]` entry boundary, so + a decoy `ref:` can be planted in string content; those are skipped and the + scan keeps LOOKING past them, the same discipline `_pins_to_job_workflow_sha` + applies — stopping at a decoy drops the real site out of coverage entirely + rather than merely scoring it weaker. """ - # Asked of nearly every line of every job (the `else` arm of the walk), and - # a `steps.`/`steps[` substring is a precondition of all three patterns — - # so answer the common case before paying for the comment strip and the - # regexes. - if "steps." not in line and "steps[" not in line: - return None - match = _steps_output_match(_strip_comment(line), cont) - if not match: - return None - step_id = match.group("id") or match.group("id_idx") - out = match.group("out") or match.group("out_idx") - return (step_id, out) + if cont: + return [(code, False)] + match = _REF_KEY_VALUE_RE.match(code) + if match: + return [(match.group("value"), False)] + return [ + (_flow_entry_value(code, entry.end()), True) + for entry in _REF_FLOW_KEY_RE.finditer(code) + if _outside_quotes(code, entry.start()) + ] # Operands `||` falls THROUGH, so a leading one of these still lets the step # output be the value (BE-8215). `||` returns the first TRUTHY operand, not the -# first operand — reading `leading` as "nothing precedes the output" reported +# first operand, so reading `leading` as "nothing precedes the output" reported # `${{ false || steps.x.outputs.ref }}` as unguarded unconditionally, with a # message no edit can satisfy, even though it resolves to exactly the output a # guard covers. GitHub's expression language treats these five as false. _FALSEY_OPERANDS = frozenset(("false", "''", '""', "0", "null")) +def _falls_through(operand): + """True when `||` cannot stop at `operand` — so what follows may be the ref. + + The five falsey literals, plus a bare `steps..outputs.`: an + unresolved output is `''`, which is falsey, so `${{ steps.a.outputs.ref || + steps.b.outputs.ref }}` really can resolve to `b`. That second operand only + became VISIBLE with the exhaustive reader (BE-8253) — the single-match one + swallowed it into the fallback stretch and judged `a` alone — and it is + judged in its own right, so nothing is excused by falling through here. + """ + operand = operand.strip() + return operand in _FALSEY_OPERANDS or bool(_BARE_STEPS_OUTPUT_RE.match(operand)) + + def _lead_reaches_output(lead): """True when `lead` cannot stop the step output being the ref's value. - `lead` is what precedes `steps..outputs.` inside the `${{ … }}`. - Empty is the common case. Anything else has to be a chain of `||` operands - that all fall through — a truthy leading operand (`'main' ||`) wins on - every runner, and nothing the consuming step or the resolver can do will - change that, so the site is unguarded unconditionally. + `lead` is what precedes `steps..outputs.` inside the `${{ … }}`, + operands ahead of it included. Empty is the common case. Anything else has + to be a chain of `||` operands that all fall through — a truthy leading + operand (`'main' ||`) wins on every runner, and nothing the consuming step + or the resolver can do will change that, so the site is unguarded + unconditionally. """ lead = lead.strip() if not lead: @@ -1003,32 +1067,129 @@ def _lead_reaches_output(lead): # Not an `||` chain at all — a `(`, a `format(`, an `&&`. Unrecognized # rather than proven harmless, so judge it the fail-closed way. return False - return all( - operand.strip() in _FALSEY_OPERANDS for operand in lead[:-2].split("||") - ) + return all(_falls_through(operand) for operand in lead[:-2].split("||")) + + +def _strict_steps_output_sites(value, flow): + """[(id, out, leading)] for every step output the strict tier can read. + EXHAUSTIVE, where the old reader stopped at its first match: every + interpolation in `value`, and every top-level `||` operand inside each one. + Two whole shapes hid behind that first match, and in both the operand + nobody judged is a live checkout ref (BE-8253): -def _steps_output_site(line, cont=False): - """(step id, output name, leading) for the walk's judgment, else None. + - `ref: "${{ steps.a.outputs.ref }}${{ steps.b.outputs.ref || 'main' }}"` — + the block pattern's greedy `.*` landed on the LAST interpolation, so `a` + was never judged. Both interpolations feed the value, so both must be. + - `ref: ${{ steps.a.outputs.ref || steps.b.outputs.ref }}` — the fallback + stretch swallowed `b`, so a covered `a` passed the whole site while `b` + reached an uncovered output. - `leading` is True when the ref expression's first `||` operand IS the step - output — the step-output twin of `_leading_operand_reaches_input`. GitHub's - `||` returns the first truthy operand, so `ref: ${{ 'main' || - steps.x.outputs.ref }}` reads the output while resolving to a mutable - branch on every runner; neither a hard-guard resolver nor the exact `if:` - can change that, so a non-leading output is unguarded unconditionally. - Judged from the `lead` group of the SAME match rather than from the line's - first interpolation, because a quoted decoy sibling can put an unrelated - interpolation ahead of the real one. + `leading` is per operand and reads the operands AHEAD of it, so the + single-operand answers are unchanged: `${{ 'main' || }}` is still + non-leading and `${{ false || }}` still reaches the output. + """ + interp_re = _STEPS_INTERP_FLOW_RE if flow else _STEPS_INTERP_RE + sites = [] + for interp in interp_re.finditer(value): + operands = interp.group("body").split("||") + for pos, operand in enumerate(operands): + match = _STEPS_OUTPUT_OPERAND_RE.match(operand) + if match is None: + continue + lead = match.group("lead") + if pos: + lead = "||".join(operands[:pos]) + "||" + lead + step_id = match.group("id") or match.group("id_idx") + out = match.group("out") or match.group("out_idx") + sites.append((step_id, out, _lead_reaches_output(lead))) + return sites + + +# Recorded in place of a site list when the LOOSE tier sees a step output the +# STRICT tier could not account for. A module constant so the walk, the +# recorder and `check_dir` all name the same state. +UNPARSED = "unparsed" + + +def _steps_output_sites(line, cont=False): + """Every step output `line`'s `ref:` reads, `UNPARSED`, or None (BE-8253). + + None when the value names no step output at all — the common case, and the + answer for prose that merely mentions one, since comments are stripped + first for the same reason `_pins_to_job_workflow_sha` strips them: + `ref: main # was ${{ steps.x.outputs.ref }}` is not a checkout resolved + from a step output. The loose tier runs only on the comment-stripped VALUE, + so it cannot fire on that line either. + + `UNPARSED` when the loose tier counts more mentions than the strict tier + accounted for. The value plainly reaches a step output and this reader + cannot say WHICH, or under what condition — so it must not answer "no + site", which is the fail-open this state closes: the lint passed + `${{ steps.x.outputs.ref || format('refs/heads/{0}', 'main') }}` while + failing the identical workflow spelled bare. + + Otherwise the list, one tuple per operand, for `_record_steps_output` to + judge INDEPENDENTLY. `cont=True` judges a CONTINUATION line instead: the + value under a `ref: >-` / `ref: |` key, which carries no `ref:` of its own. """ + # Asked of nearly every line of every job (the `else` arm of the walk), and + # a `steps.`/`steps[` substring is a precondition of every pattern below — + # so answer the common case before paying for the comment strip and the + # scan. if "steps." not in line and "steps[" not in line: return None - match = _steps_output_match(_strip_comment(line), cont) - if match is None: + code = _strip_comment(line) + for value, flow in _ref_values(code, cont): + mentions = len(_LOOSE_STEPS_OUTPUT_RE.findall(value)) + if not mentions: + continue + sites = _strict_steps_output_sites(value, flow) + # A strictly-read operand contains exactly one mention and operands do + # not overlap, so the strict tier can never account for MORE than the + # loose tier saw; fewer means at least one mention went unread. + return sites if len(sites) >= mentions else UNPARSED + return None + + +def steps_output_ref(line, cont=False): + """(step id, output name) for the FIRST step output `line`'s `ref:` reads. + + Answers only "which step produced this ref" — never whether the checkout is + covered. `ref_checkouts` decides that, because the answer depends on which + steps the job has already walked past. None when the value reads none, and + None for an `UNPARSED` value too: there is no id to name where the reader + could not read one. + """ + sites = _steps_output_sites(line, cont) + if not isinstance(sites, list) or not sites: return None - step_id = match.group("id") or match.group("id_idx") - out = match.group("out") or match.group("out_idx") - return step_id, out, _lead_reaches_output(match.group("lead")) + step_id, out, _ = sites[0] + return step_id, out + + +def _reported_step_output(line, state): + """The `steps..outputs.` an error message for `state` should NAME. + + A `ref:` can read SEVERAL step outputs (BE-8253) and only one of them need + be the offending operand, so naming the first would point the author at a + sibling that is fine. `'non-leading'` is answerable from the line alone — + it is the first operand something precedes — while `'dangling'` is a + property of the JOB, not the line, so a multi-output value falls back to + the placeholders rather than naming the wrong step. Same fallback the + `ref: >-` continuation spelling already takes, which reports the KEY line + and keeps its value below it. + """ + sites = _steps_output_sites(line) + if not isinstance(sites, list) or not sites: + return "", "" + if state == "non-leading": + for step_id, out, leading in sites: + if not leading: + return step_id, out + if len(sites) == 1: + return sites[0][0], sites[0][1] + return "", "" def _consumes_input(text): @@ -1724,9 +1885,24 @@ def _skips_on_empty_output(lines, idx, step_id, out): return False -def _record_steps_output(found, lines, idx, resolved, resolvers, step_ids): +def _record_steps_output(found, lines, idx, sites, resolvers, step_ids): """Record the `ref:` at `idx`, which reads `steps..outputs.`. + `sites` is EVERY step output the value reads (BE-8253), and every one of + them is judged INDEPENDENTLY: an operand reaching an uncovered step output + is not excused by a covered sibling, and for a value concatenating two + interpolations both feed the ref, so both must be covered. The strongest + requirement wins — the site is guarded only when all of them are. + + `sites` is `UNPARSED` when the value plainly reads a step output the strict + reader could not account for. There is nothing to resolve then, and the one + honest answer is to REFUSE the expression rather than pass it unexamined, + so the site is recorded `'unparsed'` for `check_dir` to name a supported + spelling. Gated by `_is_ref_input` like every other state below it: a + job-level `outputs:` mapping or a `run:` heredoc holding an unparseable + expression is not a checkout, and hard-failing one is the false-CI-failure + channel the dangling check already had to close once. + Records NOTHING only when `` names a real step declared AHEAD of the consuming one that never touches `workflows_ref` — a `git rev-parse`, a release lookup — which is not this lint's subject, and demanding an @@ -1763,43 +1939,73 @@ def _record_steps_output(found, lines, idx, resolved, resolvers, step_ids): and there is no expression to compare here — the `if:` tests the resolved VALUE, so guard strength is moot on this path. """ - step_id, out, leading = resolved if not _is_ref_input(lines, idx): # Not an action input, so not a checkout — a job-level `outputs:` # mapping, a `run:` heredoc. Nothing to judge and nothing to fail. return - if step_id not in resolvers: - declared = step_ids.get(step_id) - bounds = _consuming_step_bounds(lines, idx) - consumer_start = bounds[0] if bounds is not None else idx - # A step's OWN id must not excuse a ref consuming it — during the - # step's `with:` evaluation its output does not exist yet — so the - # boundary is the consuming STEP's first line, not the `ref:` line. - if declared is not None and declared < consumer_start: - # OUT OF SCOPE, and asked ahead of operand order on purpose: a - # `ref:` resolved from a real earlier step that never touches - # `workflows_ref` is not this lint's subject in ANY operand - # position. Judging `leading` first reported - # `ref: ${{ inputs.pr_sha || steps.detect.outputs.sha }}` — a - # perfectly ordinary checkout — as 'non-leading', printing an - # error that demands an operand reorder which CHANGES the - # workflow's runtime semantics. - return - if leading: - # No step of that id runs ahead of the checkout, and the output IS - # what the expression resolves to: `''` at runtime, which - # `actions/checkout` reads as the default branch. - found.append((idx + 1, False, False, "dangling")) - return - # A dangling id whose operand does not lead falls through to the - # non-leading verdict below: the leading operand wins, so the output is - # never consulted, "no such step" is a red herring, and fixing the id - # changes nothing. Operand order is the only fix. - if not leading: - found.append((idx + 1, False, False, "non-leading")) + if sites == UNPARSED: + found.append((idx + 1, False, False, UNPARSED)) return - guarded = _skips_on_empty_output(lines, idx, step_id, out) - found.append((idx + 1, False, guarded, True)) + verdicts = [] + for step_id, out, leading in sites: + if step_id not in resolvers: + declared = step_ids.get(step_id) + bounds = _consuming_step_bounds(lines, idx) + consumer_start = bounds[0] if bounds is not None else idx + # A step's OWN id must not excuse a ref consuming it — during the + # step's `with:` evaluation its output does not exist yet — so the + # boundary is the consuming STEP's first line, not the `ref:` line. + if declared is not None and declared < consumer_start: + # OUT OF SCOPE, and asked ahead of operand order on purpose: a + # `ref:` resolved from a real earlier step that never touches + # `workflows_ref` is not this lint's subject in ANY operand + # position. Judging `leading` first reported + # `ref: ${{ inputs.pr_sha || steps.detect.outputs.sha }}` — a + # perfectly ordinary checkout — as 'non-leading', printing an + # error that demands an operand reorder which CHANGES the + # workflow's runtime semantics. An operand this lint has no + # claim on neither fails the site nor vouches for its siblings. + continue + if leading: + # No step of that id runs ahead of the checkout, and the + # output IS what this operand resolves to: `''` at runtime, + # which `actions/checkout` reads as the default branch. + verdicts.append("dangling") + else: + # A dangling id whose operand does not lead falls to the + # non-leading verdict: the leading operand wins, so the output + # is never consulted, "no such step" is a red herring, and + # fixing the id changes nothing. Operand order is the only fix. + verdicts.append("non-leading") + continue + # `step_id` names a real resolver-tracked step, so the one question + # left is operand order — judged before guard strength for the same + # reason as above: when the leading operand wins, the output is never + # consulted, so a covered resolver is a red herring and fixing the + # guard changes nothing. + if not leading: + verdicts.append("non-leading") + continue + # Coverage is ONLY the consuming step's own exact non-empty `if:` on + # this output (BE-8221) — `resolvers` proves membership now, nothing + # about guard strength: a fail-closed resolver proves it rejects an + # empty INPUT, nothing about the value it writes to `$GITHUB_OUTPUT` + # (a sanitize-to-`''` branch, or a dropped/renamed output write, still + # hands the checkout an empty ref). + verdicts.append(bool(_skips_on_empty_output(lines, idx, step_id, out))) + if not verdicts: + # Every operand was out of scope — the same drop the single-operand + # reader made, for the same reason. + return + # A failing operand decides the site, and its state decides the REMEDY the + # message prints, so the two states with their own message come first. + # `'non-leading'` outranks `'dangling'` for the reason it is judged first + # above: no change to the id or the step order can fix operand order. + for state in ("non-leading", "dangling"): + if state in verdicts: + found.append((idx + 1, False, False, state)) + return + found.append((idx + 1, False, all(verdicts), True)) def ref_checkouts(lines): @@ -1831,13 +2037,16 @@ def ref_checkouts(lines): fail-closed resolver does not exempt its consumer (BE-8221): `is_guard_step` proves input rejection, not output non-emptiness. These sites never earn the fallback-strength exemption either, because the `if:` tests the - resolved value rather than an expression. `via_step_output` is four-state - (BE-8215), every non-`False` value truthy so the unguarded projection needs - no change: `False` (the ref names the input), `True` (a step output), - `'dangling'` — a step output whose id matches no step declared before the - consuming one, so the expression is `''` at runtime and the checkout takes - the default branch unconditionally — or `'non-leading'`, a step output the - expression does not start with, so something ahead of it decides the value. + resolved value rather than an expression. `via_step_output` is five-state + (BE-8215, BE-8253), every non-`False` value truthy so the unguarded + projection needs no change: `False` (the ref names the input), `True` (a + step output, every operand of it covered), `'dangling'` — a step output + whose id matches no step declared before the consuming one, so the + expression is `''` at runtime and the checkout takes the default branch + unconditionally — `'non-leading'`, a step output the expression does not + start with, so something ahead of it decides the value — or `'unparsed'`, + a value that plainly reads a step output in a spelling this reader cannot + judge at all, which used to record no site and pass. """ aliases = env_aliases(lines) ref_res = _ref_use_res(aliases) @@ -1909,24 +2118,44 @@ def ref_checkouts(lines): pending = None continue pending_parts.append(_strip_comment(line)) - resolved = _steps_output_site(line, cont=True) - if resolved is None and len(pending_parts) > 1: + resolved = _steps_output_sites(line, cont=True) + if not isinstance(resolved, list) and len(pending_parts) > 1: # Ask the FOLDED value — what the runtime actually - # sees — only once the single line has failed, so the - # common one-line spelling keeps its exact behavior and - # the join can only ever ADD a site. The `[^}]` bounds - # still cannot cross a `}}`, so a join can never span - # two interpolations. - resolved = _steps_output_site(" ".join(pending_parts), cont=True) - if resolved is not None: - # The `ref: >-` / `ref: |` spelling of the resolve-then- - # consume shape. Judged from the same place as the block - # form — the KEY line is the checkout, and it is the key - # line's own step that must carry the skip `if:`. + # sees — only once more than one physical line has + # been seen, so the common one-line spelling keeps its + # exact behavior and the join can only ever ADD a + # site or complete a parse the lone line could not. + joined_resolved = _steps_output_sites( + " ".join(pending_parts), cont=True + ) + if joined_resolved is not None: + resolved = joined_resolved + if isinstance(resolved, list): + # A complete parse. The `ref: >-` / `ref: |` spelling + # of the resolve-then-consume shape, judged from the + # same place as the block form — the KEY line is the + # checkout, and it is the key line's own step that + # must carry the skip `if:`. _record_steps_output( found, lines, pending[0], resolved, resolvers, step_ids ) pending = None + elif resolved == UNPARSED: + joined = " ".join(pending_parts) + if joined.count("${{") <= joined.count("}}"): + # The interpolation is already CLOSED — not still + # folding across a further line — so no later + # line can complete a parse this reader cannot + # make. Refuse it now rather than risk the site + # being dropped if the scalar has no further line + # to trigger the "scalar closed" fall-through + # below (the last field of the last step). + found.append((pending[0] + 1, False, False, UNPARSED)) + pending = None + # Otherwise the `${{` this line opened is still + # unclosed, so keep the scalar pending: a later line + # may still complete the strict-tier parse the way + # the plain `|| ` fold does. continue # Scalar closed — fall through and judge this line normally. pending = None @@ -1999,7 +2228,7 @@ def ref_checkouts(lines): pending = (i, _indent(line)) pending_parts = [] else: - resolved = _steps_output_site(line) + resolved = _steps_output_sites(line) if resolved is not None: _record_steps_output(found, lines, i, resolved, resolvers, step_ids) return found @@ -2014,7 +2243,9 @@ def unguarded_ref_checkouts(lines): the consuming step's own `if:` — and BOTH are the wrong advice for a `'dangling'` site, where no step with that id precedes the checkout at all and the fix is the id itself, or a `'non-leading'` one, where the fix is - operand order and no guard anywhere can substitute for it (BE-8215). + operand order and no guard anywhere can substitute for it (BE-8215), or an + `'unparsed'` one, where the fix is to rewrite the expression in a spelling + the lint can judge (BE-8253). """ return [ (lineno, fb, via_step) @@ -2127,6 +2358,30 @@ def check_dir(workflows_dir, exempt=KNOWN_EXEMPT): ) for lineno, uses_fallback, via_step_output in unguarded_ref_checkouts(lines): + if via_step_output == UNPARSED: + # The value reads a step output in a spelling this lint cannot + # judge (BE-8253). Every other remedy below presumes a parse — + # naming an id, an operand order, an `if:` on a known output — + # so the only honest instruction is "write one of the two + # spellings that ARE judged". Deliberately no expression parser: + # an unknown spelling asks its author for a supported one. + errors.append( + "::error file=%s,line=%d::%s checks out at a `ref:` that " + "reads a `steps..outputs.` this lint cannot " + "parse, so it cannot tell whether the checkout is guarded " + "— and an unparsed ref used to pass silently while the " + "same workflow spelled bare failed. Unrecognized " + "spellings include a fallback containing a brace " + "(`|| format('refs/heads/{0}', 'main')`), a parenthesized " + "operand (`(steps..outputs.) || 'main'`), and " + "`&&` in place of `||`. Rewrite the ref as a bare " + "`${{ steps..outputs. }}` with the exact " + "non-empty `if:` on this step, or as that expression with " + "a trailing `|| ` fallback — the supported " + "spellings in .github/workflow-pins/README.md. " + "See BE-8253." % (path, lineno, name) + ) + continue if via_step_output in ("dangling", "non-leading"): # Name the ACTUAL id and output where the reported line still # holds the expression, so a typo — the first cause the @@ -2134,7 +2389,7 @@ def check_dir(workflows_dir, exempt=KNOWN_EXEMPT): # The `ref: >-` continuation spelling reports the KEY line and # keeps its value below it, so fall back to the placeholders # there rather than naming the wrong step. - step_id, out = steps_output_ref(lines[lineno - 1]) or ("", "") + step_id, out = _reported_step_output(lines[lineno - 1], via_step_output) if via_step_output == "dangling": # The `ref:` reads a step output whose id matches NO step # declared before the consuming one (BE-8215). The BE-8130 diff --git a/.github/workflow-pins/tests/test_check_workflow_pins.py b/.github/workflow-pins/tests/test_check_workflow_pins.py index 663af664..fda08021 100644 --- a/.github/workflow-pins/tests/test_check_workflow_pins.py +++ b/.github/workflow-pins/tests/test_check_workflow_pins.py @@ -2213,6 +2213,28 @@ def test_a_folded_ref_split_across_lines_is_read_as_one_expression(self): ) self.assertEqual(self._jobs(self.RESOLVER + guarded), []) + def test_a_folded_unparseable_ref_split_across_lines_is_still_refused(self): + # The fold-join (BE-8220) and the two-tier reader (BE-8253) compose: a + # spelling this reader can never parse — a TRAILING `&&` — split + # across the same two physical lines the fold test above joins into a + # PARSEABLE expression. The single first line alone reads `UNPARSED` + # (an unclosed `${{`), which must not be finalized early — that would + # report the site before the second line is ever read, and on a + # single-continuation-line scalar it would also just be correct by + # accident. Joining confirms the interpolation is genuinely + # unparseable rather than merely incomplete, and refuses it — the + # fold must never let a site that used to record nothing regress to + # silently recording nothing again. + split = ( + " - name: Load assets\n" + " uses: actions/checkout@abc\n" + " with:\n" + " ref: >-\n" + " ${{ steps.resolve_ref.outputs.ref &&\n" + " 'main' }}\n" + ) + self.assertEqual(self._states(self.RESOLVER + split), [(False, False, "unparsed")]) + def test_a_fallback_containing_a_comma_is_still_read(self): # `[^,}]` is the FLOW form's entry boundary and nothing else's. # Carrying it into the block form dropped every fallback holding a @@ -2300,6 +2322,278 @@ def test_the_dangling_error_names_the_actual_step_id(self): self.assertIn("no step `resolve_reff` precedes", error) self.assertNotIn("", error) + # ------------------------------------------------------------------ + # The two-tier reader (BE-8253). One regex per line gives one verdict per + # line, so a `ref:` value the strict reader cannot chew — or one holding + # SEVERAL step outputs — used to record no site and pass the lint, while + # the identical workflow spelled bare failed. Loose tier: does the + # comment-stripped VALUE mention a step output at all? Strict tier: every + # interpolation, every top-level `||` operand. Loose > strict = refuse. + # ------------------------------------------------------------------ + + def _states(self, steps): + """(uses_fallback, guarded, via_step_output) for each site in one job.""" + return [ + (fb, guarded, via) + for _, fb, guarded, via in cwp.ref_checkouts(self._wrap(steps).split("\n")) + ] + + def _second_resolver(self, base, step_id="lookup"): + """`base` re-declared under a second id, so a two-operand `ref:` can + have each of its operands covered — or not — independently.""" + other = base.replace("id: resolve_ref", "id: %s" % step_id).replace( + "Resolve the asset ref", "Resolve the %s ref" % step_id + ) + self.assertNotEqual(other, base, "fixture drifted") + return other + + def test_a_fallback_containing_a_brace_is_refused_not_skipped(self): + # The `}` in `{0}` breaks the fallback stretch, so the strict reader + # matches nothing and the line used to leave the lint entirely — a + # confirmed fail-open through the real CLI: this workflow passed while + # the identical one spelled bare failed. + ref = "${{ steps.resolve_ref.outputs.ref || format('refs/heads/{0}', 'main') }}" + steps = self.RESOLVER + self._step_output_checkout(self.EXACT_IF, ref=ref) + self.assertEqual(self._states(steps), [(False, False, "unparsed")]) + self.assertEqual(len(self._jobs(steps)), 1) + + def test_a_parenthesized_operand_is_refused_not_skipped(self): + # `)` after the output name matches neither `||` nor `}}`, so the + # strict reader stops — but the value plainly reads a step output. + ref = "${{ (steps.resolve_ref.outputs.ref) || 'main' }}" + steps = self.RESOLVER + self._step_output_checkout(self.EXACT_IF, ref=ref) + self.assertEqual(self._states(steps), [(False, False, "unparsed")]) + + def test_an_and_operator_after_the_output_is_refused_not_skipped(self): + # Only `||` is read. `&&` is wrong in BOTH arms at runtime — truthy + # checks out at the mutable literal, falsey resolves to '' and checkout + # takes the default branch — so the one shape that must NOT happen is + # the lint staying quiet about it. + ref = "${{ steps.resolve_ref.outputs.ref && 'main' }}" + steps = self.RESOLVER + self._step_output_checkout(self.EXACT_IF, ref=ref) + self.assertEqual(self._states(steps), [(False, False, "unparsed")]) + + def test_the_flow_and_continuation_spellings_refuse_it_too(self): + # Same treatment on all three spellings — a shape refused in the block + # form and skipped in the other two is the one-line bypass again. + expr = "${{ steps.resolve_ref.outputs.ref && 'main' }}" + flow = ( + " - name: Load assets\n" + " uses: actions/checkout@abc\n" + ' with: {repository: Comfy-Org/github-workflows, ref: "%s"}\n' % expr + ) + scalar = ( + " - name: Load assets\n" + " uses: actions/checkout@abc\n" + " with:\n" + " ref: >-\n" + " %s\n" % expr + ) + for spelling, steps in (("flow", flow), ("block scalar", scalar)): + with self.subTest(spelling=spelling): + self.assertEqual( + self._states(self.RESOLVER + steps), [(False, False, "unparsed")] + ) + + def test_a_flow_fallback_holding_a_comma_is_refused_not_skipped(self): + # `[^,}]` is the flow form's entry boundary, so a fallback carrying a + # comma is a spelling the strict reader genuinely cannot read there. + # The block form reads it (`test_a_fallback_containing_a_comma_is_still_read`); + # the flow form now REFUSES it instead of dropping the site. + flow = ( + " - name: Load assets\n" + " uses: actions/checkout@abc\n" + ' with: {ref: "${{ steps.resolve_ref.outputs.ref || \'a,b\' }}"}\n' + ) + self.assertEqual( + self._states(self.RESOLVER + flow), [(False, False, "unparsed")] + ) + + def test_a_commented_out_step_output_is_not_a_ref_use(self): + # The loose tier is permissive by design, so it MUST run on the + # comment-stripped value only — prose naming a step output is not a + # checkout resolved from one, and reporting it would fail a workflow + # whose `ref:` is a plain literal. + checkout = self._step_output_checkout(ref="main # was ${{ steps.resolve_ref.outputs.ref }}") + self.assertEqual(self._states(self.RESOLVER + checkout), []) + + def test_an_unparseable_expression_outside_a_with_input_is_not_a_checkout(self): + # The `_is_ref_input` gate, on the new state. The walk asks EVERY line + # of the job, so a job-level `outputs:` mapping and a `run:` heredoc + # emitting fixture YAML both reach the recorder — and hard-failing a + # compliant workflow with an error naming a checkout where there is no + # checkout is the false-CI-failure channel BE-8215 already had to close + # once. Do not reopen it. + expr = "${{ steps.resolve_ref.outputs.ref && 'main' }}" + heredoc = ( + " - name: Write a fixture\n" + " run: |\n" + " cat <<'EOF' > f.yml\n" + " ref: %s\n" + " EOF\n" % expr + ) + self.assertEqual(self._states(self.RESOLVER + heredoc), []) + job_outputs = ( + "name: F\non:\n workflow_call:\njobs:\n" + " job0:\n" + " runs-on: ubuntu-latest\n" + " outputs:\n" + " ref: %s\n" + " steps:\n" % expr + ) + self.RESOLVER + self.assertEqual(cwp.ref_checkouts(job_outputs.split("\n")), []) + + def test_a_quoted_decoy_does_not_hide_an_unparseable_real_ref(self): + # The decoy discipline and the new state compose: a `ref:` planted in + # string content meets the flow matcher's `[{,]` boundary, and stopping + # there would drop the REAL ref — which is itself unparseable — out of + # coverage entirely. + flow = ( + " - name: Load assets\n" + " uses: actions/checkout@abc\n" + ' with: {path: "x, ref: ${{ steps.decoy.outputs.ref }}", ' + 'ref: "${{ (steps.resolve_ref.outputs.ref) || \'main\' }}"}\n' + ) + self.assertEqual( + self._states(self.RESOLVER + flow), [(False, False, "unparsed")] + ) + + def test_both_concatenated_interpolations_are_judged(self): + # The block pattern's greedy `.*` landed on the LAST interpolation, so + # the first was never judged at all. Both feed the ref's value, so both + # must be covered independently — and since BE-8221 a resolver's own + # guard strength buys its consumer nothing, hard or soft: coverage is + # ONLY the consuming step's own exact `if:`. `both_hard` proves the + # first half — two fail-closed resolvers and no `if:` at all still + # report the site, because neither resolver's strength is examined. + ref = "${{ steps.lookup.outputs.ref }}${{ steps.resolve_ref.outputs.ref }}" + checkout = self._step_output_checkout(ref='"%s"' % ref) + both_hard = self._second_resolver(self.HARD_RESOLVER) + self.HARD_RESOLVER + self.assertEqual(len(self._jobs(both_hard + checkout)), 1) + # A step carries only one `if:`, so covering the SECOND operand's + # exact condition — the one the old single-operand reader judged — + # still fails: the first operand is untouched, and one covered + # sibling does not excuse the other (BE-8253). + covered_second = self._second_resolver(self.RESOLVER) + self.HARD_RESOLVER + steps = covered_second + self._step_output_checkout( + self.EXACT_IF, ref='"%s"' % ref + ) + self.assertEqual(len(self._jobs(steps)), 1) + # …and only the first: the same failure, from the other side. + covered_first = self._second_resolver(self.HARD_RESOLVER) + self.RESOLVER + first_if = " if: steps.lookup.outputs.ref != ''\n" + steps = covered_first + self._step_output_checkout(first_if, ref='"%s"' % ref) + self.assertEqual(len(self._jobs(steps)), 1) + + def test_every_or_operand_must_be_covered(self): + # `A || B` with both operands step outputs: the fallback stretch + # swallowed `B`, so a covered `A` passed the whole site while `B` + # reached an output nothing had judged. An unresolved `A` really is + # falsey, so `B` really can be the ref. + ref = "${{ steps.lookup.outputs.ref || steps.resolve_ref.outputs.ref }}" + checkout = self._step_output_checkout(ref=ref) + both_hard = self._second_resolver(self.HARD_RESOLVER) + self.HARD_RESOLVER + # A fail-closed resolver on EITHER operand still buys nothing without + # the consuming step's own `if:` (BE-8221) — the site is reported. + self.assertEqual(len(self._jobs(both_hard + checkout)), 1) + # Leading operand's resolver is hard, trailing one's is soft — neither + # matters without an `if:`, so the site still fails either way. + lead_hard = self._second_resolver(self.HARD_RESOLVER) + self.RESOLVER + self.assertEqual(len(self._jobs(lead_hard + checkout)), 1) + # …and the trailing operand is not reported `'non-leading'` merely for + # sitting behind another step output: `||` falls through an empty one. + self.assertEqual(self._states(lead_hard + checkout), [(False, False, True)]) + # Covering only the TRAILING operand's exact `if:` still fails: the + # leading one is untouched, and a covered sibling excuses nothing. + steps = lead_hard + self._step_output_checkout(self.EXACT_IF, ref=ref) + self.assertEqual(len(self._jobs(steps)), 1) + + def test_a_second_operand_naming_no_step_is_dangling(self): + # The exhaustive reader sees the operand the old one swallowed, so a + # typo in it is caught rather than excused by a covered leading operand. + ref = "${{ steps.resolve_ref.outputs.ref || steps.resolve_reff.outputs.ref }}" + steps = self.HARD_RESOLVER + self._step_output_checkout(ref=ref) + self.assertEqual(self._states(steps), [(False, False, "dangling")]) + + def test_the_supported_spellings_are_unchanged(self): + # No behavior change for a parsed single-operand site — the whole point + # of leaving the strict reader alone and adding a tier around it. + for ref in ( + "${{ steps.resolve_ref.outputs.ref }}", + "${{ steps.resolve_ref.outputs.ref || 'main' }}", + "${{ steps.resolve_ref.outputs.ref || 'a,b' }}", + ): + with self.subTest(ref=ref): + self.assertEqual( + self._states( + self.RESOLVER + self._step_output_checkout(self.EXACT_IF, ref=ref) + ), + [(False, True, True)], + ref, + ) + self.assertEqual( + self._states(self.RESOLVER + self._step_output_checkout(ref=ref)), + [(False, False, True)], + ref, + ) + + def test_a_continuation_value_with_a_literal_prefix_is_a_site(self): + # The block form always read a value that only CONTAINS the + # interpolation (`ref: refs/heads/${{ … }}`); the continuation form used + # to demand the whole line BE one, so the same concatenation under + # `ref: >-` recorded no site. Reading the value the same way in all + # three spellings is the point — a checkout is not less of a checkout + # for having a prefix, and the value still resolves through the output. + scalar = ( + " - name: Load assets\n" + "%s" + " uses: actions/checkout@abc\n" + " with:\n" + " ref: >-\n" + " refs/heads/${{ steps.resolve_ref.outputs.ref }}\n" + ) + self.assertEqual( + self._states(self.RESOLVER + scalar % ""), [(False, False, True)] + ) + self.assertEqual(self._jobs(self.RESOLVER + scalar % self.EXACT_IF), []) + + def test_an_unparsed_ref_gets_its_own_error_text(self): + # Every other remedy presumes a parse — an id to name, an operand order + # to fix, an `if:` on a known output — so printing one of those here + # sends the author to edit something the lint never read. The message + # has to name the SUPPORTED spellings instead. + ref = "${{ steps.resolve_ref.outputs.ref || format('refs/heads/{0}', 'main') }}" + error = self._one_error( + self.RESOLVER + self._step_output_checkout(self.EXACT_IF, ref=ref) + ) + self.assertIn("cannot parse", error) + self.assertIn("BE-8253", error) + self.assertIn(".github/workflow-pins/README.md", error) + for wrong_remedy in ("BE-8130", "does not START with it", "no step `"): + self.assertNotIn(wrong_remedy, error) + + def test_a_multi_operand_error_does_not_name_the_wrong_step(self): + # The dangling message's whole value is naming the id to fix, and with + # two operands only one of them is the offending one — naming the first + # would send the author to edit a sibling that is fine. Step existence + # is a property of the JOB, not the line, so the placeholders are the + # honest answer there; a NON-leading operand is answerable from the + # line itself, so that one is still named exactly. + dangling = "${{ steps.resolve_ref.outputs.ref || steps.resolve_reff.outputs.ref }}" + error = self._one_error( + self.HARD_RESOLVER + self._step_output_checkout(ref=dangling) + ) + self.assertIn("no step `` precedes", error) + self.assertNotIn("no step `resolve_ref` precedes", error) + non_leading = "${{ steps.resolve_ref.outputs.ref || 'main' || steps.lookup.outputs.ref }}" + error = self._one_error( + self._second_resolver(self.HARD_RESOLVER) + + self.HARD_RESOLVER + + self._step_output_checkout(ref=non_leading) + ) + self.assertIn("steps.lookup.outputs.ref", error) + self.assertNotIn("", error) + def test_this_repos_own_workflows_guard_every_ref_checkout(self): root = os.path.normpath( os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "workflows")