mirror of
https://github.com/ivuorinen/go-test-sarif.git
synced 2026-01-26 03:04:09 +00:00
99 lines
1.8 KiB
Markdown
99 lines
1.8 KiB
Markdown
# go-test-sarif
|
|
|
|
`go-test-sarif` is a CLI tool 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**.
|
|
- Generates structured test failure reports for **security and compliance tools**.
|
|
- Works as a **standalone CLI tool**.
|
|
|
|
## 📦 Installation
|
|
|
|
### Using `go install`
|
|
|
|
```sh
|
|
go install github.com/ivuorinen/go-test-sarif-action@latest
|
|
```
|
|
|
|
## 🛠️ Usage
|
|
|
|
### CLI Usage
|
|
|
|
```sh
|
|
go test -json ./... > go-test-results.json
|
|
go-test-sarif go-test-results.json go-test-results.sarif
|
|
```
|
|
|
|
## 📜 Output Example
|
|
|
|
SARIF report example:
|
|
|
|
```json
|
|
{
|
|
"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:
|
|
|
|
```sh
|
|
git clone https://github.com/ivuorinen/go-test-sarif-action.git
|
|
cd go-test-sarif-action
|
|
go build -o go-test-sarif ./cmd/main.go
|
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
```
|
|
|
|
Run tests:
|
|
|
|
```sh
|
|
go test ./...
|
|
```
|
|
|
|
Run linting:
|
|
|
|
```sh
|
|
go vet ./...
|
|
golangci-lint run
|
|
```
|
|
|
|
## 📄 License
|
|
|
|
This project is licensed under the **MIT License**.
|
|
|
|
## 🤝 Contributing
|
|
|
|
Pull requests are welcome! For major changes, open an issue to discuss them.
|