Add function for parsing DOI definition files (#172)

Add a Rego builtin called `attest.internals.parse_library_definition`
for parsing the DOI definition files in
https://github.com/docker-library/official-images/tree/master/library.
This will allow us to verify DOI provenance fields against these files
which are the source of truth for DOI images.

This function just defers to
https://github.com/docker-library/bashbrew/blob/master/manifest/rfc2822.go.
This commit is contained in:
Jonny Stoten
2024-09-27 12:32:24 +01:00
committed by GitHub
parent 2a4bef091e
commit 4ca962b70c
8 changed files with 144 additions and 43 deletions

View File

@@ -0,0 +1,18 @@
package def_parse_test
import rego.v1
test_parse_library_definition if {
def := `Maintainers: me <me@example.com> (@me)
GitRepo: blah
Tags: 1, 2, 3
GitCommit: fa105cb3c26c8f0e87d7dbb1bf5293691ac2f688
File: Dockerfile.foo`
result := attest.internals.parse_library_definition(def)
definition := result.value
definition.Entries[0].GitRepo == "blah"
definition.Entries[0].GitCommit == "fa105cb3c26c8f0e87d7dbb1bf5293691ac2f688"
definition.Entries[0].Tags == ["1", "2", "3"]
definition.Entries[0].File == "Dockerfile.foo"
}

View File

@@ -0,0 +1,9 @@
package attest_test
import rego.v1
import data.attest
test_sucess if {
attest.success
}

View File

@@ -1,7 +0,0 @@
package attest
import rego.v1
test_sucess if {
success
}