8000 feat: document annotations for source data, hash, format, and URL by jhoward-lm · Pull Request #153 · bomctl/bomctl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: document annotations for source data, hash, format, and URL #153

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

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

jhoward-lm
Copy link
Contributor
@jhoward-lm jhoward-lm commented Sep 11, 2024

Description

This PR adds annotations in the database for each document fetched. The new annotation names are:

  • bomctl_annotation_source_data - bytes content of fetched document
  • bomctl_annotation_source_hash - hash of fetched document
  • bomctl_annotation_source_format - original format of fetched document
  • bomctl_annotation_source_url - URL of fetched document

Fixes #68

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • updated Go tests
  • run locally and verify database contents

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Signed-off-by: Jonathan Howard <jonathan.w.howard@lmco.com>
@jhoward-lm jhoward-lm added the enhancement New feature or request label Sep 11, 2024
@jhoward-lm jhoward-lm self-assigned this Sep 11, 2024
@jhoward-lm jhoward-lm requested a review from a team as a code owner September 11, 2024 16:27
@jhoward-lm jhoward-lm linked an issue Sep 11, 2024 that may be closed by this pull request
Signed-off-by: Jonathan Howard <jonathan.w.howard@lmco.com>
Copy link
Member
@ashearin ashearin left a comment

Choose a reason for hiding this comment

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

Looks good!

One question about this section in fetch: (69-75)

if err := backend.SetUniqueAnnotation(
		doc.GetMetadata().GetId(), db.SourceURLAnnotation, sbomURL,
	); err != nil {
		return nil, fmt.Errorf(
			"applying unique annotation %s to %s: %w", db.SourceURLAnnotation, doc.GetMetadata().GetId(), err,
		)
	}

Formatting is a little weird, but we're setting the source url as the id in the annotations? Might have that backwards, but are we using this anywhere currently? If not, whats the plan

@jhoward-lm
Copy link
Contributor Author

we're setting the source url as the id in the annotations? Might have that backwards, but are we using this anywhere currently? If not, whats the plan

So, the signature is SetUniqueAnnotation(documentID string, name string, value string) error. In other words, "on the document with documentID, set a unique annotation named name with a value of value".

Not currently using it anywhere, but it enables the capability to look up a document in the database by its URL if it was already fetched. One use case might be if we're trying to fetch a whole tree we can check the database first to see if the external reference was already fetched, and if so, use it.

@jhoward-lm jhoward-lm merged commit ebfe126 into main Sep 16, 2024
9 checks passed
@jhoward-lm jhoward-lm deleted the 68-extended-ent-schemas branch September 16, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Extended ent schemas
3 participants
0