(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestParseAndDisplayPoutineOutput(t *testing.T) { |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | stdout string |
| 19 | targetFile string |
| 20 | verbose bool |
| 21 | expectedOutput []string |
| 22 | expectError bool |
| 23 | expectedCount int |
| 24 | }{ |
| 25 | { |
| 26 | name: "single file with error finding", |
| 27 | stdout: `{ |
| 28 | "findings": [ |
| 29 | { |
| 30 | "rule_id": "injection", |
| 31 | "purl": "pkg:localrepo/localrepo/local?repository_url=.", |
| 32 | "meta": { |
| 33 | "path": ".github/workflows/test.lock.yml", |
| 34 | "line": 30, |
| 35 | "details": "Sources: github.event.inputs.name" |
| 36 | } |
| 37 | } |
| 38 | ], |
| 39 | "rules": { |
| 40 | "injection": { |
| 41 | "id": "injection", |
| 42 | "title": "Injection with Arbitrary External Contributor Input", |
| 43 | "description": "The pipeline contains an injection into bash or JavaScript", |
| 44 | "level": "error" |
| 45 | } |
| 46 | } |
| 47 | }`, |
| 48 | targetFile: ".github/workflows/test.lock.yml", |
| 49 | expectedOutput: []string{ |
| 50 | ".github/workflows/test.lock.yml:30:1: error: [error] injection: Injection with Arbitrary External Contributor Input - Sources: github.event.inputs.name", |
| 51 | }, |
| 52 | expectError: false, |
| 53 | expectedCount: 1, |
| 54 | }, |
| 55 | { |
| 56 | name: "single file with warning finding", |
| 57 | stdout: `{ |
| 58 | "findings": [ |
| 59 | { |
| 60 | "rule_id": "pr_runs_on_self_hosted", |
| 61 | "purl": "pkg:localrepo/localrepo/local?repository_url=.", |
| 62 | "meta": { |
| 63 | "path": ".github/workflows/test.lock.yml", |
| 64 | "line": 112, |
| 65 | "details": "runs-on: ubuntu-slim" |
| 66 | } |
| 67 | } |
| 68 | ], |
| 69 | "rules": { |
| 70 | "pr_runs_on_self_hosted": { |
| 71 | "id": "pr_runs_on_self_hosted", |
| 72 | "title": "Pull Request Runs on Self-Hosted GitHub Actions Runner", |
nothing calls this directly
no test coverage detected