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

オープン
#154 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, json
領域
devtools, security

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Java
スター
15
フォーク
12
平均マージ
2日 10時間
マージ済み PR(30日)
17

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ballerina-platform/static-code-analysis-tool のほかの issue

ballerina-platform/static-code-analysis-tool の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。