Skip to content
Draft
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
13 changes: 4 additions & 9 deletions containeranalysis/snippets/create_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@ def create_note(note_id: str, project_id: str) -> types.grafeas.Note:
grafeas_client = client.get_grafeas_client()
project_name = f"projects/{project_id}"
note = {
"vulnerability": {
"details": [
{
"affected_cpe_uri": "your-uri-here",
"affected_package": "your-package-here",
"affected_version_start": {"kind": Version.VersionKind.MINIMUM},
"fixed_version": {"kind": Version.VersionKind.MAXIMUM},
}
]
"attestation": {
"hint": {
"human_readable_name": "my-attestation-authority",
}
}
Comment on lines +30 to 34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This change to create an attestation note will cause tests in samples_test.py to fail. The tests create a note using this function and then attempt to create a vulnerability occurrence for it (e.g., in test_create_occurrence). This will raise an error because the occurrence kind must match the note kind. The test suite needs to be updated to work with attestation notes.

Copy link
Author

@lvoelz lvoelz Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acknowledged - will look at the other samples in this repo and align them with attestations accordingly. can hold off on reviewing until those have been added.

}
response = grafeas_client.create_note(
Expand Down