Skip to content
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

update(build/registry): make sure new artifacts requirements contain … #185

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions build/registry/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"os"
"strconv"
"strings"

"github.com/blang/semver"
Expand All @@ -31,7 +30,7 @@ import (

const (
rulesEngineAnchor = "- required_engine_version"
engineVersionKey = "engine_version"
engineVersionKey = "engine_version_semver"
)

// ErrReqNotFound error when the requirements are not found in the rulesfile.
Expand Down Expand Up @@ -65,13 +64,21 @@ func rulesfileRequirement(filePath string) (*oci.ArtifactRequirement, error) {

// Split the requirement and parse the version to semVer.
tokens := strings.Split(fileScanner.Text(), ":")
reqVer, err := semver.ParseTolerant(tokens[1])
reqVer, err := semver.Parse(tokens[1])
if err != nil {
return nil, fmt.Errorf("unable to parse to semVer the version requirement %q", tokens[1])
reqVer, err = semver.ParseTolerant(tokens[1])
if err != nil {
return nil, fmt.Errorf("unable to parse requirement %q: expected a numeric value or a valid semver string", tokens[1])
}
reqVer = semver.Version{
Major: 0,
Minor: reqVer.Major,
Patch: 0,
}
}

return &oci.ArtifactRequirement{
Name: engineVersionKey,
Version: strconv.FormatUint(reqVer.Major, 10),
Version: reqVer.String(),
}, nil
}
2 changes: 1 addition & 1 deletion rules/falco-incubating_rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Starting with version 8, the Falco engine supports exceptions.
# However the Falco rules file does not use them by default.
- required_engine_version: "0.26.0"
- required_engine_version: 0.26.0

- macro: open_write
condition: (evt.type in (open,openat,openat2) and evt.is_open_write=true and fd.typechar='f' and fd.num>=0)
Expand Down
2 changes: 1 addition & 1 deletion rules/falco-sandbox_rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Starting with version 8, the Falco engine supports exceptions.
# However the Falco rules file does not use them by default.
- required_engine_version: "0.26.0"
- required_engine_version: 0.26.0

# Currently disabled as read/write are ignored syscalls. The nearly
# similar open_write/open_read check for files being opened for
Expand Down
2 changes: 1 addition & 1 deletion rules/falco_rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Starting with version 8, the Falco engine supports exceptions.
# However the Falco rules file does not use them by default.
- required_engine_version: "0.26.0"
- required_engine_version: 0.26.0

# Currently disabled as read/write are ignored syscalls. The nearly
# similar open_write/open_read check for files being opened for
Expand Down
Loading