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

ear: remove productId from default policy #620

Merged
merged 1 commit into from
Dec 11, 2024
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
20 changes: 8 additions & 12 deletions attestation-service/src/policy_engine/opa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,19 @@ mod tests {
"sourced_data",
];

fn dummy_reference(product_id: u64, svn: u64, launch_digest: String) -> String {
fn dummy_reference(svn: u64, launch_digest: String) -> String {
json!({
"reference": {
"productId": [product_id.to_string()],
"svn": [svn.to_string()],
"launch_digest": [launch_digest]
}
})
.to_string()
}

fn dummy_input(product_id: u64, svn: u64, launch_digest: String) -> String {
fn dummy_input(svn: u64, launch_digest: String) -> String {
json!({
"sample": {
"productId": product_id.to_string(),
"svn": svn.to_string(),
"launch_digest": launch_digest
}
Expand All @@ -221,14 +219,12 @@ mod tests {
}

#[rstest]
#[case(5,5,1,1,"aac43bb3".to_string(),"aac43bb3".to_string(),3,2)]
#[case(5,4,1,1,"aac43bb3".to_string(),"aac43bb3".to_string(),3,97)]
#[case(5,5,1,1,"aac43bb4".to_string(),"aac43bb3".to_string(),33,2)]
#[case(5,5,2,1,"aac43bb4".to_string(),"aac43bb3".to_string(),33,97)]
#[case(1,1,"aac43bb3".to_string(),"aac43bb3".to_string(),3,2)]
#[case(2,1,"aac43bb3".to_string(),"aac43bb3".to_string(),3,97)]
#[case(1,1,"aac43bb4".to_string(),"aac43bb3".to_string(),33,2)]
#[case(2,1,"aac43bb4".to_string(),"aac43bb3".to_string(),33,97)]
#[tokio::test]
async fn test_evaluate(
#[case] pid_a: u64,
#[case] pid_b: u64,
#[case] svn_a: u64,
#[case] svn_b: u64,
#[case] digest_a: String,
Expand All @@ -243,8 +239,8 @@ mod tests {

let output = opa
.evaluate(
&dummy_reference(pid_a, svn_a, digest_a),
&dummy_input(pid_b, svn_b, digest_b),
&dummy_reference(svn_a, digest_a),
&dummy_input(svn_b, digest_b),
&default_policy_id,
&EAR_RULES,
)
Expand Down
4 changes: 0 additions & 4 deletions attestation-service/src/token/ear_default_policy.rego
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ sample_executables := 3 if {
# verifications needed to demonstrate that these are genuine/
# supported.
sample_hardware := 2 if {
# The sample attester does not report any productId.
# This is an exmple of how a real platform might identify the hardware
# that is running.
input.sample.productId in data.reference.productId
input.sample.svn in data.reference.svn
}

Expand Down
Loading