Skip to content

Commit 170d721

Browse files
authored
Protobuf lint job (#280)
* Use new actions on local attest Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]> * Correct proto package and lint files Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]> * buf generate Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]> * Run buf linter as presubmit Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]> --------- Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
1 parent b3836f8 commit 170d721

File tree

5 files changed

+99
-93
lines changed

5 files changed

+99
-93
lines changed

hack/verify-protos.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ set -o xtrace
99
source hack/common.sh
1010

1111
make proto
12+
13+
# Check if the proto definitions need updating
1214
git diff --exit-code || exit_with_msg "Code from protocol definitions is not up to date. Please run 'make proto' and commit the result"
15+
16+
# Check the format of the proto files
17+
buf lint || exit_with_msg "The proto files have linting errors. Please run 'buf lint' and fix them before committing"

pkg/policy/policy.pb.go

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/provenance/provenance.pb.go

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/v1/policy.proto

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,51 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
syntax = "proto3";
5-
package ampel.v1;
5+
package in_toto_attestation.predicates.source_provenance.v1;
66

77
import "google/protobuf/timestamp.proto";
88

9+
// buf:lint:ignore PACKAGE_SAME_GO_PACKAGE
910
option go_package = "github.com/slsa-framework/slsa-source-poc/pkg/policy";
1011

1112
// The repository policy definition
1213
message RepoPolicy {
13-
string canonical_repo = 1 [json_name="canonical_repo"];
14-
repeated ProtectedBranch protected_branches = 2 [json_name="protected_branches"];
15-
optional ProtectedTag protected_tag = 3;
14+
string canonical_repo = 1 [json_name = "canonical_repo"];
15+
repeated ProtectedBranch protected_branches = 2 [json_name = "protected_branches"];
16+
optional ProtectedTag protected_tag = 3;
1617
}
1718

1819
// When a branch requires multiple controls, they must all be enabled
1920
// at or before 'since'.
2021
message ProtectedBranch {
21-
string name = 1;
22-
google.protobuf.Timestamp since = 2;
23-
// We override this string with slsa.SlsaSourceLevel
24-
string target_slsa_source_level = 3;
25-
bool require_review = 4;
26-
repeated OrgStatusCheckControl org_status_check_controls = 5 [json_name="org_status_check_controls"];
22+
string name = 1;
23+
google.protobuf.Timestamp since = 2;
24+
// We override this string with slsa.SlsaSourceLevel
25+
string target_slsa_source_level = 3;
26+
bool require_review = 4;
27+
repeated OrgStatusCheckControl org_status_check_controls = 5 [json_name = "org_status_check_controls"];
2728
}
2829

2930
// The controls required for protected tags.
3031
message ProtectedTag {
31-
google.protobuf.Timestamp since = 1;
32-
bool tag_hygiene = 2;
32+
google.protobuf.Timestamp since = 1;
33+
bool tag_hygiene = 2;
3334
}
3435

3536
// Used by orgs to require that specific 'checks' are run on protected
3637
// branches and to associate those checks with a control name to include
3738
// in provenance and VSAs.
3839
// https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#require-status-checks-to-pass-before-merging
39-
message OrgStatusCheckControl {
40-
// The property to record in the VSA if the conditions are met.
41-
// MUST start with `ORG_SOURCE_`.
42-
// We'll overide this with slsa.ControlName
43-
string property_name = 1;
44-
45-
// These controls have their own start time to enable orgs to enable
46-
// new ones without violating continuity on other controls.
47-
google.protobuf.Timestamp since = 2;
48-
49-
// The name of the 'Status Check' as reported in the GitHub UI & API.
50-
string check_name = 3;
40+
message OrgStatusCheckControl {
41+
// The property to record in the VSA if the conditions are met.
42+
// MUST start with `ORG_SOURCE_`.
43+
// We'll overide this with slsa.ControlName
44+
string property_name = 1;
45+
46+
// These controls have their own start time to enable orgs to enable
47+
// new ones without violating continuity on other controls.
48+
google.protobuf.Timestamp since = 2;
49+
50+
// The name of the 'Status Check' as reported in the GitHub UI & API.
51+
string check_name = 3;
5152
}

proto/v1/provenance.proto

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
syntax = "proto3";
5-
package ampel.v1;
5+
package in_toto_attestation.predicates.source_provenance.v1;
66

77
import "google/protobuf/timestamp.proto";
88

9+
// buf:lint:ignore PACKAGE_SAME_GO_PACKAGE
910
option go_package = "github.com/slsa-framework/slsa-source-poc/pkg/provenance";
1011

1112
// The predicate that encodes source provenance data.
1213
// The git commit this corresponds to is encoded in the surrounding statement.
1314
message SourceProvenancePred {
14-
// The commit preceding 'Commit' in the current context.
15-
string prev_commit = 1;
16-
string repo_uri = 2;
17-
string activity_type = 3;
18-
string actor = 4;
19-
string branch = 5;
20-
optional google.protobuf.Timestamp created_on = 6;
21-
// TODO: get the author of the PR (if this was from a PR).
22-
23-
// The controls enabled at the time this commit was pushed.
24-
repeated Control controls = 7;
15+
// The commit preceding 'Commit' in the current context.
16+
string prev_commit = 1;
17+
string repo_uri = 2;
18+
string activity_type = 3;
19+
string actor = 4;
20+
string branch = 5;
21+
optional google.protobuf.Timestamp created_on = 6;
22+
// TODO: get the author of the PR (if this was from a PR).
23+
24+
// The controls enabled at the time this commit was pushed.
25+
repeated Control controls = 7;
2526
}
2627

27-
message Control {
28-
// The name of the control
29-
string name = 1;
30-
// The time from which this control has been continuously enforced/observed.
31-
google.protobuf.Timestamp since = 2;
28+
message Control {
29+
// The name of the control
30+
string name = 1;
31+
// The time from which this control has been continuously enforced/observed.
32+
google.protobuf.Timestamp since = 2;
3233
}
3334

3435
message TagProvenancePred {
35-
string repo_uri = 1;
36-
string actor = 2;
37-
string tag = 3;
38-
optional google.protobuf.Timestamp created_on = 4;
39-
40-
// The tag related controls enabled at the time this tag was created/updated.
41-
repeated Control controls = 7;
42-
repeated VsaSummary vsa_summaries = 8;
36+
string repo_uri = 1;
37+
string actor = 2;
38+
string tag = 3;
39+
optional google.protobuf.Timestamp created_on = 4;
40+
41+
// The tag related controls enabled at the time this tag was created/updated.
42+
repeated Control controls = 7;
43+
repeated VsaSummary vsa_summaries = 8;
4344
}
4445

4546
// Summary of a summary
4647
message VsaSummary {
47-
repeated string source_refs = 1;
48-
repeated string verifiedLevels = 2;
48+
repeated string source_refs = 1;
49+
repeated string verified_levels = 2 [json_name = "verifiedLevels"];
4950
}
50-

0 commit comments

Comments
 (0)