upload-sarif: relative paths beginning with `./` are not handled correctly
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- github-actions
- Área
- security
Línea de trabajo
Comienza con el punto de entrada upload-sarif y reproduce la diferencia indicada entre foo/bar y ./foo/bar, utilizando las indicaciones enlazadas sobre rutas SARIF y el contexto de RFC 3986. Investiga si la implementación relevante está en este repositorio o en el mecanismo de ingesta de SARIF de GitHub; se considera terminado cuando las referencias relativas se resuelven a archivos del repositorio, se renderizan vistas previas y aparecen de forma coherente en las pull requests.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.6k
- Forks
- 493
- Merge medio
- 1 d 13 h
- PR fusionados (30 d)
- 44
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/codeql-action
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
github/codeql-action#4052 · 4 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
github/codeql-action#4078 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
github/codeql-action#4008 · 9 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
github/codeql-action#3978 · 4 comentarios · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
github/codeql-action#3915 · 6 comentarios · 3 reacciones ·
Todos los issues de github/codeql-action
Issues similares
-
[Bug]: Discord Activity titles with emoji are rejected as over 80 characters when they are not Abiertoclawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
supermomonga/zcode-acp#24 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
growthbook/growthbook#7100 ·
-
triage
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100