Report related locations for ballerina:13 and ballerina:14 findings

Aperta
#154 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, json
Ambito
devtools, security

Direzione di ricerca

Start with the Scanner API's Reporter.reportIssue and the Issue class, then trace SecretValueResolver and SecretChecker for the secret rules ballerina:13 and ballerina:14. The resolver must record each declaration it passes through, and the SARIF, JSON and HTML reporters need to emit them. Done means a fixture like fixture shows its declaration as a related location in all three reports.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Area/Core Type/New Feature
Problem

ballerina:13 and ballerina:14 trace a secret's value back to where it is written, and report the finding where the value is used. That's how SonarSource S6437 and CodeQL report hard-coded credentials too. The trace is thrown away once the rule is chosen, so the finding doesn't say where the value comes from:

string fixture = "fixed-secret";
connect(password = fixture);          // ballerina:14
login(secret = fixture);              // ballerina:14

The JSON and SARIF reports give only the use site and the rule's general description. To triage connect(password = fixture), the reader has to work out that fixture is a variable holding a fixed value and find where it is declared. The same applies to a configurable's literal default, which is reported as ballerina:13 at every use.

Proposed Solution

Scanner API: related locations on an issue.

  • Add a Reporter.reportIssue overload that also takes a list of related locations.
  • Add an Issue accessor that returns them. It is empty for issues reported without any.
  • This is additive, so existing analyzers and library rules are unaffected.

Secret rules: record the origin. SecretValueResolver already follows the value through variables, constants, configurable defaults and mapping fields. It would collect the declaration of each one on the way, and SecretChecker would report them as the issue's related locations. Along a chain such as a → b → "literal", every declaration is recorded.

Reports

  • SARIF: emit the related locations as relatedLocations, with a message such as "The fixed value is defined here".
  • JSON: add them to each issue.
  • HTML: list them on the issue.
"location": {"filePath": "main.bal", "startLine": 2, "snippet": "fixture"},
"relatedLocations": [{"filePath": "main.bal", "startLine": 1, "snippet": "fixture"}]
Alternatives
  • Report ballerina:14 once at the declaration, instead of at each use. This breaks consistency with ballerina:13 and with how other SAST tools report credential sinks, and it hides how many places use the value.
  • Name the variable in the message only, without a location. Readers still have to find the declaration, and SARIF viewers can't link to it.
Version

0.13.0

Lingua principale
Java
Stelle
15
Fork
12
Merge medio
2g 10h
PR unite (30g)
17

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ballerina-platform/static-code-analysis-tool

Tutte le issue di ballerina-platform/static-code-analysis-tool

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.