upload-sarif: relative paths beginning with `./` are not handled correctly
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- github-actions
- Ambito
- security
Direzione di ricerca
Inizia dal punto di ingresso upload-sarif e riproduci la differenza segnalata tra foo/bar e ./foo/bar, utilizzando le indicazioni collegate sui percorsi SARIF e il contesto di RFC 3986. Verifica se l’implementazione rilevante si trova in questo repository o nel meccanismo di acquisizione SARIF di GitHub; il lavoro è completato quando i riferimenti relativi vengono risolti nei file del repository, le anteprime vengono visualizzate e compaiono in modo coerente nelle pull request.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello!
I'm reporting what I believe to be a bug in GitHub's SARIF consumption. This bug is probably happening somewhere deeper in GitHub's SARIF consumption machinery but upload-sarif is the main user-facing entrypoint for that machinery, so I'm filing the report here. Please let me know if a better discussion venue exists and I'd be happy to continue this elsewhere 🙂
Description
GitHub's documentation says the following about paths in SARIF inputs:
Code scanning interprets results that are reported with relative paths as relative to the root of the repository analyzed. If a result contains an absolute URI, the URI is converted to a relative URI. The relative URI can then be matched against a file committed to the repository.
This, combined with the fact that SARIF stipulates RFC 3986 for artifactLocation URIs suggests that relative paths should be able to include . and .., as these path components are well-defined in RFC 3986.
However, if a SARIF file contains a relative URI like ./foo/bar, GitHub appears to fail to resolve that URL to a path in the repository being scanned. This results in suboptimal finding presentation:
- Findings are not rendered on PRs, since GitHub doesn't think the finding URLs match repository paths;
- Findings are rendered under "Code scanning alerts" but show "Preview unavailable" instead of a proper synopsis/extraction of the source file.
Here is a screenshot of the above behavior, demonstrating the "Preview unavailable" behavior because the path (./tests/integration/test-data/issue-612-repro/action.yml) starts with a ./:
For contrast, here's a similar finding rendering correctly because it doesn't begin with ./:
Expected behavior
I expect GitHub's SARIF ingestion to handle URIs that begin with (or contain) relative references, since SARIF stipulates RFC 3986 for URIs and RFC 3986 permits relative references. More generally, I believe many code-scanning tools produce relative references (like ./foo) by default and would benefit from not having to specialize their handling for GitHub's SARIF consumer.
Actual behavior
Relative URIs like foo/bar work correctly (resolving relative to the repository root), while relative URIs like ./foo/bar do not work correctly.
Workarounds
The primary workarounds here are:
- "Normalize" relative URIs from
./foo/bartofoo/bar. This is possible, but non-trivial in the general case (e.g../foo/bar/../baz), and requires more pre-processing on the generated SARIF than the specification stipulates. - Switch entirely to absolute URIs, and use SARIF's features (like
invocations[0].workingDirectory.uri) to help GitHub ingest and transform paths into appropriate relative URIs. I've had limited success making this work: the SARIF ingestor appears to be very fickle about absolute paths.
Overall, I think both of these workarounds are non-ideal, and add additional burden to SARIF producers to pre-process their inputs/offer a GitHub specific "quirks mode" beyond what SARIF stipulates. I think it would be fantastic if GitHub could instead support these kinds of relative paths!
Additional context
I ran into this behavior within zizmor, which supports SARIF as an output format and encourages people to use it when integrating with GitHub. Some original issue context: https://github.com/woodruffw/zizmor/issues/604, https://github.com/woodruffw/zizmor/issues/571.
Additionally, I've observed that GitHub's behavior around equivalent relative paths (e.g. foo/bar and ./foo/bar) is somewhat mixed: ./foo/bar doesn't produce a preview, but results for foo/bar and ./foo/bar are deduplicated against each other. That makes me think that some degree of normalization/equivalence checking is happening in GitHub's SARIF processing, just not at the point needed to handle previews correctly.
Please let me know if there's any other information I can provide!
CC @kommendorkapten
- Lingua principale
- TypeScript
- Stelle
- 1.6k
- Fork
- 493
- Merge medio
- 1g 13h
- PR unite (30g)
- 44
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/codeql-action
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/codeql-action#4052 · 4 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
github/codeql-action#4078 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
github/codeql-action#4008 · 9 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
github/codeql-action#3978 · 4 commenti · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
github/codeql-action#3915 · 6 commenti · 3 reazioni ·
Tutte le issue di github/codeql-action
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
dennys-bd/agent-hive#184 ·
-
Add: hunch Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
AbdelStark/awesome-typesafe#104 ·
-
ai-observability bug team/ai-observability
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vicharanashala/fln#563 ·