This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move everything related to verification to internal/verification package * Rename package common to model * Update README * Update license file
- Loading branch information
Showing
11 changed files
with
161 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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,4 +1,3 @@ | ||
{ | ||
"**/*.go": "// Copyright 2022 The Project Oak Authors", | ||
"**/BUILD": "# Copyright 2022 The Project Oak Authors" | ||
"**/*.go": ["// Licensed under the Apache License, Version 2.0 (the \"License\");"] | ||
} |
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2023 The Project Oak Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package verification | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/pelletier/go-toml" | ||
) | ||
|
||
// ReferenceValues specify expected values to verify provenances against. | ||
type ReferenceValues struct { | ||
// Allow list of binary digests. | ||
BinarySHA256Digests []string `toml:"binary_sha256_digests"` | ||
// If true, expect that the provenance has a non-empty build command. | ||
WantBuildCmds bool `toml:"want_build_cmds"` | ||
// Allow list of builder image digests that are trusted for building the binary. | ||
BuilderImageSHA256Digests []string `toml:"builder_image_sha256_digests"` | ||
// The URI of the repo holding the resources the binary is built from. | ||
RepoURI string `toml:"repo_uri"` | ||
// Allow list of builders trusted to build the binary. | ||
TrustedBuilders []string `toml:"trusted_builders"` | ||
} | ||
|
||
// LoadReferenceValuesFromFile loads reference values from a toml file in the given path and returns an instance of ReferenceValues. | ||
func LoadReferenceValuesFromFile(path string) (*ReferenceValues, error) { | ||
tomlTree, err := toml.LoadFile(path) | ||
if err != nil { | ||
return nil, fmt.Errorf("couldn't load toml file: %v", err) | ||
} | ||
|
||
referenceValues := ReferenceValues{} | ||
if err := tomlTree.Unmarshal(&referenceValues); err != nil { | ||
return nil, fmt.Errorf("couldn't unmarshal toml file: %v", err) | ||
} | ||
|
||
return &referenceValues, nil | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2023 The Project Oak Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package verification | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/project-oak/transparent-release/internal/testutil" | ||
) | ||
|
||
const ( | ||
testdataPath = "../../testdata/" | ||
) | ||
|
||
func TestParseReferenceValues(t *testing.T) { | ||
path := filepath.Join(testdataPath, "reference_values.toml") | ||
referenceValues, err := LoadReferenceValuesFromFile(path) | ||
if err != nil { | ||
t.Fatalf("couldn't load reference values file: %v", err) | ||
} | ||
|
||
testutil.AssertEq(t, "binary digests[0]", referenceValues.BinarySHA256Digests[0], "d059c38cea82047ad316a1c6c6fbd13ecf7a0abdcc375463920bd25bf5c142cc") | ||
testutil.AssertEq(t, "want build cmd", referenceValues.WantBuildCmds, false) | ||
testutil.AssertEq(t, "builder image digests[0]", referenceValues.BuilderImageSHA256Digests[0], "9e2ba52487d945504d250de186cb4fe2e3ba023ed2921dd6ac8b97ed43e76af9") | ||
} |
Oops, something went wrong.