mirror of
https://github.com/aquasecurity/linux-bench.git
synced 2025-02-22 22:25:33 +01:00
Merge pull request #69 from aquasecurity/test-order
Make unit tests work under GitHub Actions
This commit is contained in:
commit
ca36ec8929
3 changed files with 8930 additions and 8974 deletions
28
app_test.go
28
app_test.go
|
@ -5,15 +5,9 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
cfgdir = "./cfg"
|
||||
ver = "1.1.0"
|
||||
path string
|
||||
)
|
||||
|
||||
// Tests all standard linux-bench defintion files
|
||||
func TestGetDefinitionFilePath(t *testing.T) {
|
||||
d, err := os.Open(cfgdir)
|
||||
d, err := os.Open("./cfg")
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %s\n", err)
|
||||
}
|
||||
|
@ -24,6 +18,7 @@ func TestGetDefinitionFilePath(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, ver := range vers {
|
||||
t.Logf("%v", ver)
|
||||
_, err := getDefinitionFilePath(ver)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %s\n", err)
|
||||
|
@ -31,20 +26,13 @@ func TestGetDefinitionFilePath(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGetControls(t *testing.T) {
|
||||
var err error
|
||||
path, err = getDefinitionFilePath(ver)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %s\n", err)
|
||||
}
|
||||
|
||||
_, err = getControls(path, nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunControls(t *testing.T) {
|
||||
cfgDir = "./hack"
|
||||
path, err := getDefinitionFilePath("test-definitions")
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %s\n", err)
|
||||
}
|
||||
|
||||
control, err := getControls(path, nil)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %s\n", err)
|
||||
|
|
File diff suppressed because it is too large
Load diff
35
hack/test-definitions/definitions.yaml
Normal file
35
hack/test-definitions/definitions.yaml
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
controls:
|
||||
version: 0.1
|
||||
id: 1
|
||||
description: "Test YAMl file"
|
||||
type: "hack"
|
||||
groups:
|
||||
- id: 1.1
|
||||
description: "Filesystem Configuration"
|
||||
checks:
|
||||
- id: 1.1.1
|
||||
description: "Disable unused filesystems"
|
||||
checks:
|
||||
- id: 1.1.1.1.a
|
||||
description: "Ensure mounting of cramfs filesystems is disabled"
|
||||
audit: "echo hello"
|
||||
tests:
|
||||
test_items:
|
||||
- flag: "hello"
|
||||
set: true
|
||||
remediation: |
|
||||
Correct something about this test
|
||||
scored: true
|
||||
- id: 1.1.1.1.b
|
||||
description: "Ensure mounting of cramfs filesystems is disabled"
|
||||
audit: "echo hello=false"
|
||||
tests:
|
||||
test_items:
|
||||
- flag: "hello"
|
||||
compare:
|
||||
op: eq
|
||||
value: "false"
|
||||
set: true
|
||||
remediation: |
|
||||
Put your remediation here
|
Loading…
Add table
Reference in a new issue