report --finding ignores --out unless --format is also given

オープン 初心者向け
#128 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
cli

調査の方向性

internal/cli/report.go の runReport(47〜61行目)から始めてください。ここでは、空の --format が --out の値に関係なく terminal に強制されています。その後、書き込みの流れを internal/cli/scan.go の emit(131〜166行目)まで追い、Output.Dir が参照される前に出力が標準出力へ描画される箇所を確認してください。修正方法は、--out も空の場合にのみ terminal をデフォルトにするか、--format を --out と一緒に指定するようユーザーに伝える明確な usage エラーを返すことです。internal/cli に、--out を指定し --format を指定しない --finding を対象とするテーブル駆動テストを追加し、go test ./internal/cli を実行してください。完了の条件は、選択された findings が出力ディレクトリに出力されること、またはコマンドが明確な usage エラーで終了することです。

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

説明

bug good first issue severity: low

Summary

spackle report <run> --finding <id> --out <dir> prints the report to the terminal, writes nothing to <dir>, and exits 0. With --finding, an empty --format always becomes terminal, even when --out was given. The code comment says a selection is "written under --out".

Where

  • internal/cli/report.go:47-61 (runReport)
  • internal/cli/scan.go:131-166 (emit renders txt to stdout before it looks at Output.Dir)

Details

// The stored reports hold every finding, so a selection is printed,
// or written under --out, and never pointed at the stored files.
if g.format == "" {
	cfg.Output.Formats = []string{"terminal"}
}

Impact

A user or script that asks for a filtered report written to a directory gets no files and no error.

Steps to reproduce

  1. spackle report latest --finding <id> --out ./r
  2. The report prints to the terminal and ./r stays empty. Exit code 0.

Suggested fix

Default to terminal only when --out is also empty. Otherwise keep the configured formats and write them under --out, or refuse with "give --format with --out".

Acceptance criteria

  • report --finding <id> --out <dir> writes the selected findings to <dir> in the configured formats, or exits with a usage error that says what to add.
  • A test in internal/cli covers --finding with --out and no --format.

Getting started

  • Relevant files: internal/cli/report.go, internal/cli/scan.go
  • How to run tests: go test ./internal/cli

Filed by repo-audit/full-audit at fffef43. Severity: low. Effort: S. audit-key: bug|internal/cli/report.go|runReport

主要言語
Go
スター
0
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

TMHSDigital/Spackle のほかの issue

TMHSDigital/Spackle の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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