Files
go-test-sarif/.github
renovate[bot] 449a3fe31b fix(github-action): update github/codeql-action (v3.28.13 → v3.28.15)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-08 05:05:43 +00:00
..
2025-03-24 00:10:47 +02:00
2025-03-28 00:10:54 +02:00
2025-03-24 00:10:47 +02:00

go-test-sarif and go-test-sarif-action

go-test-sarif is a CLI tool and GitHub Action for converting go test -json output into SARIF format, making it compatible with GitHub Security Tab and other SARIF consumers.

🚀 Features

  • Converts go test -json output to SARIF format.
  • GitHub Action integration for CI/CD pipelines.
  • Generates structured test failure reports for security and compliance tools.
  • Works as a standalone CLI tool.

📦 Installation

Using go install

go install github.com/ivuorinen/go-test-sarif-action@latest

Using Docker

docker pull ghcr.io/ivuorinen/go-test-sarif-action:latest

🛠️ Usage

CLI Usage

go test -json ./... > go-test-results.json
go-test-sarif go-test-results.json go-test-results.sarif

Docker Usage

docker run --rm -v $(pwd):/workspace ghcr.io/ivuorinen/go-test-sarif-action go-test-results.json go-test-results.sarif

GitHub Action Usage

Add the following step to your GitHub Actions workflow:

- name: Convert JSON to SARIF
  uses: ivuorinen/go-test-sarif-action@v1
  with:
    test_results: go-test-results.json

To upload the SARIF file to GitHub Security Tab, add:

- name: Upload SARIF report
  uses: github/codeql-action/upload-sarif@v2
  with:
    sarif_file: go-test-results.sarif

📜 Output Example

SARIF report example:

{
  "version": "2.1.0",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "Go Test",
          "informationUri": "https://golang.org/cmd/go/#hdr-Test_packages",
          "version": "1.0.0"
        }
      },
      "results": [
        {
          "ruleId": "go-test-failure",
          "level": "error",
          "message": {
            "text": "Test failed"
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "github.com/example/package"
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

🏗 Development

Clone the repository and build the project:

git clone https://github.com/ivuorinen/go-test-sarif-action.git
cd go-test-sarif
go build -o go-test-sarif ./cmd/main.go

Run tests:

go test ./...

📄 License

This project is licensed under the MIT License.

🤝 Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss the changes.