-
Notifications
You must be signed in to change notification settings - Fork 38
fix(policy): policy devel lint --format removes the comments #2325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Piskoo
merged 4 commits into
chainloop-dev:main
from
Piskoo:fix-policy-yaml-comments-removal-on-format
Aug 11, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
apiVersion: workflowcontract.chainloop.dev/v1 | ||
kind: Policy | ||
metadata: | ||
name: cdx-fresh | ||
description: Checks that SBOM is maximum of 30 days old | ||
annotations: | ||
category: quickstart | ||
name: cdx-fresh | ||
description: Checks that SBOM is maximum of 30 days old | ||
annotations: | ||
category: quickstart | ||
spec: | ||
policies: | ||
- embedded: | | ||
package main | ||
|
||
import rego.v1 | ||
|
||
################################ | ||
# Common section do NOT change # | ||
################################ | ||
|
||
result := { | ||
"skipped": skipped, | ||
"violations": violations, | ||
"skip_reason": skip_reason, | ||
"ignore": ignore, | ||
} | ||
|
||
default skip_reason := "" | ||
|
||
skip_reason := m if { | ||
not valid_input | ||
m := "invalid input" | ||
} | ||
|
||
default skipped := true | ||
|
||
skipped := false if valid_input | ||
|
||
default ignore := false | ||
|
||
######################################## | ||
# EO Common section, custom code below # | ||
######################################## | ||
# Validates if the input is valid and can be understood by this policy | ||
valid_input := true | ||
|
||
limit := 30 | ||
nanosecs_per_second := (1000 * 1000) * 1000 | ||
nanosecs_per_day := ((24 * 60) * 60) * nanosecs_per_second | ||
maximum_age := limit * nanosecs_per_day | ||
|
||
# If the input is valid, check for any policy violation here | ||
violations contains msg if { | ||
sbom_ns = time.parse_rfc3339_ns(input.metadata.timestamp) | ||
exceeding = time.now_ns() - (sbom_ns + maximum_age) | ||
exceeding > 0 | ||
msg := sprintf("SBOM created at: %s which is too old (freshness limit set to %d days)", [input.metadata.timestamp, limit]) | ||
} | ||
kind: SBOM_CYCLONEDX_JSON | ||
policies: | ||
- embedded: | | ||
package main | ||
|
||
import rego.v1 | ||
|
||
################################ | ||
# Common section do NOT change # | ||
################################ | ||
|
||
result := { | ||
"skipped": skipped, | ||
"violations": violations, | ||
"skip_reason": skip_reason, | ||
"ignore": ignore, | ||
} | ||
|
||
default skip_reason := "" | ||
|
||
skip_reason := m if { | ||
not valid_input | ||
m := "invalid input" | ||
} | ||
|
||
default skipped := true | ||
|
||
skipped := false if valid_input | ||
|
||
default ignore := false | ||
|
||
######################################## | ||
# EO Common section, custom code below # | ||
######################################## | ||
# Validates if the input is valid and can be understood by this policy | ||
valid_input := true | ||
|
||
limit := 30 | ||
nanosecs_per_second := (1000 * 1000) * 1000 | ||
nanosecs_per_day := ((24 * 60) * 60) * nanosecs_per_second | ||
maximum_age := limit * nanosecs_per_day | ||
|
||
# If the input is valid, check for any policy violation here | ||
violations contains msg if { | ||
sbom_ns = time.parse_rfc3339_ns(input.metadata.timestamp) | ||
exceeding = time.now_ns() - (sbom_ns + maximum_age) | ||
exceeding > 0 | ||
msg := sprintf("SBOM created at: %s which is too old (freshness limit set to %d days)", [input.metadata.timestamp, limit]) | ||
} | ||
kind: SBOM_CYCLONEDX_JSON |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have more spaces now?
Do ew want to have 4 instead of 2? I personally like 2 spaces, any reason for using 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2333 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a bug, must have missed this, thanks!