Skip to content

Commit

Permalink
fix artifact tests
Browse files Browse the repository at this point in the history
Signed-off-by: nikpivkin <[email protected]>
  • Loading branch information
nikpivkin committed Aug 9, 2024
1 parent aaef1b3 commit 1c1c255
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 225 deletions.
6 changes: 5 additions & 1 deletion pkg/fanal/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ func (r *AnalysisResult) Sort() {

// Misconfigurations
sort.Slice(r.Misconfigurations, func(i, j int) bool {
return r.Misconfigurations[i].FilePath < r.Misconfigurations[j].FilePath
if r.Misconfigurations[i].FileType != r.Misconfigurations[j].FileType {
return r.Misconfigurations[i].FileType < r.Misconfigurations[j].FileType
} else {
return r.Misconfigurations[i].FilePath < r.Misconfigurations[j].FilePath
}
})

// Secrets
Expand Down
160 changes: 80 additions & 80 deletions pkg/fanal/artifact/local/fs_test.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# severity: HIGH
# short_code: foo-bar-baz
# recommended_action: "Remove bad stuff"

# input:
# selector:
# - type: cloud
package user.something

deny[res] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: cloud
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: kubernetes
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: kubernetes
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - "https://trivy.dev/"
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-buckets
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: kubernetes
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-buckets",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# METADATA
# title: Test policy
# description: This is a test policy.
# related_resources:
# - https://trivy.dev/
# custom:
# id: TEST001
# avd_id: AVD-TEST-0001
# severity: LOW
# short_code: no-evil
# recommended_actions: Have a cup of tea.
# input:
# selector:
# - type: kubernetes
package user.something

__rego_metadata__ := {
"id": "TEST001",
"avd_id": "AVD-TEST-0001",
"title": "Test policy",
"short_code": "no-evil",
"severity": "LOW",
"description": "This is a test policy.",
"recommended_actions": "Have a cup of tea.",
"url": "https://trivy.dev/",
}

# taken from defsec rego lib to mimic behaviour
result(msg, cause) = result {
metadata := object.get(cause, "__defsec_metadata", cause)
Expand Down
Loading

0 comments on commit 1c1c255

Please sign in to comment.