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

VulnsV2: Add missing invocation to protos and spec #434

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

puerco
Copy link
Contributor

@puerco puerco commented Jan 21, 2025

This PR updates the vulns02 protos to rename the scanner.database field (to scanner.db) and the scanner_metadata field (to just metadata) to match the vulns02 spec.

Sample generated predicate (with the go library):

{
  "scanner": {
    "uri": "pkg:github/aquasecurity/trivy@244fd47e07d1004f0aed9",
    "version": "0.19.2",
    "db": {
      "uri": "pkg:github/aquasecurity/trivy-db/commit/4c76bb580b2736d67751410fa4ab66d2b6b9b27d",
      "version": "v1-2021080612",
      "last_update": {
        "seconds": 1737495873,
        "nanos": 773202315
      }
    },
    "result": [
      {
        "id": "CVE-123",
        "severity": [
          {
            "method": "nvd",
            "score": "medium"
          },
          {
            "method": "cvss_score",
            "score": "5.2"
          }
        ]
      }
    ]
  },
  "metadata": {
    "scan_started_on": {
      "seconds": 1737495873,
      "nanos": 773202413
    },
    "scan_finished_on": {
      "seconds": 1737495873,
      "nanos": 773202481
    }
  }
}

Signed-off-by: Adolfo García Veytia (Puerco) [email protected]

@puerco puerco requested a review from a team as a code owner January 21, 2025 20:56
@puerco puerco changed the title Add missing invocation to protos and spec VulnsV2: Add missing invocation to protos and spec Jan 21, 2025
@puerco
Copy link
Contributor Author

puerco commented Jan 21, 2025

/cc @hectorj2f

@puerco
Copy link
Contributor Author

puerco commented Jan 21, 2025

I've pushed another commit renaming scanner.db to scanner.database in the documentation to match the definition in the protos. I wonder which one was wrong?

@puerco
Copy link
Contributor Author

puerco commented Jan 21, 2025

Another problem:
The example metadata shows the metadata field name as metadata:

    "metadata": {
      "scanStartedOn": "2021-08-06T17:45:50.52Z",
      "scanFinishedOn": "2021-08-06T17:50:50.52Z"
    }

Yet the protos have it as scan_metadata:

message Vulns {
Scanner scanner = 1;
ScanMetadata scan_metadata = 2;
}

Should we rename it? I would suggest changing the proto (and thus, the generated code) to avoid ugly hacks with annotations, etc. On the downside, it would be a breaking change but I think the generated libraries have not been released yet.

@marcelamelara
Copy link
Contributor

@puerco have you seen #408 ? I think that the Invocation field was actually removed in the vulns v0.2 spec.

I've also regenerated the go, python and java libraries.

No need for that :) We automatically regenerate these with the CI whenever the protos change.

@marcelamelara
Copy link
Contributor

Should we rename it? I would suggest changing the proto (and thus, the generated code) to avoid ugly hacks with annotations, etc. On the downside, it would be a breaking change but I think the generated libraries have not been released yet.

@puerco Yes! The metadata field needs to be changed in the proto.

@puerco
Copy link
Contributor Author

puerco commented Jan 21, 2025

have you seen #408

Grrr no! I missed that :( :(
OK, let me drop that change from this PR and I'll handle renaming the metadata field

@marcelamelara
Copy link
Contributor

Grrr no! I missed that :( :(
OK, let me drop that change from this PR and I'll handle renaming the metadata field

@puerco Thanks so much, sorry for the extra work!

This commit renames the scanner database field (to db) and the
scanner_metadata field (to just metadata) to match the vulns02 spec.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@puerco
Copy link
Contributor Author

puerco commented Jan 21, 2025

No worries, I should have gone through the examples :D

I rescoped the PR to handle the database and metadata inconsistency with the vulnsv2 spec (also fixed a tiny typo in the spec example). I've edited the PR body with a generated example.

Copy link
Contributor

@marcelamelara marcelamelara left a comment

Choose a reason for hiding this comment

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

LGTM @puerco ! Thanks so much for sending this!

Copy link
Member

@pxp928 pxp928 left a comment

Choose a reason for hiding this comment

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

Thanks @puerco good catch!

@pxp928 pxp928 merged commit 6e0b70a into in-toto:main Jan 23, 2025
2 checks passed
@hectorj2f
Copy link
Contributor

Thanks @puerco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants