-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add Valid() methods for TagID and Evidence #45
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
+531
−39
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8afdc02
Add Valid() methods for TagID and Evidence
Sukuna0007Abhi 011f777
add File.Valid() method and update Evidence validation
Sukuna0007Abhi dd45316
Add UUID RFC4122 variant validation and fix linting issues
Sukuna0007Abhi 3e76bd6
Update tagid.go
yogeshbdeshpande 54797d7
fix: resolve CI failures in linter and test workflows
Sukuna0007Abhi 9edaa4b
fix: resolve golangci-lint issues for v2.x compatibility
Sukuna0007Abhi dc7d4b5
fix: correct golangci-lint v2 configuration format
Sukuna0007Abhi c54309d
fix: correct golangci-lint v2 configuration format
Sukuna0007Abhi c89d821
Update .golangci.yml
yogeshbdeshpande cbbe7b8
fix: upgrade golangci-lint to v2.5.0 for Go 1.24 compatibility
Sukuna0007Abhi ceef354
fix: update linters workflow to match corim reference
Sukuna0007Abhi 67d21e8
fix: remove gosimple from optional linters (not available in v2.x)
Sukuna0007Abhi 53be192
fix: remove gosimple and update copyright years
Sukuna0007Abhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| // Copyright 2020 Contributors to the Veraison project. | ||
| // Copyright 2020-2025 Contributors to the Veraison project. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package swid | ||
|
|
||
| import "time" | ||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "time" | ||
| ) | ||
|
|
||
| // Evidence models a evidence-entry | ||
| type Evidence struct { | ||
|
|
@@ -53,3 +57,34 @@ func (e *Evidence) AddProcess(p Process) error { | |
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Valid validates the Evidence receiver to ensure it has valid required fields | ||
| func (e Evidence) Valid() error { | ||
| if e.DeviceID == "" { | ||
| return errors.New("evidence device-id is empty") | ||
| } | ||
|
|
||
| if e.Date.IsZero() { | ||
| return errors.New("evidence date is zero") | ||
| } | ||
|
|
||
| // Validate Files if present | ||
| if e.Files != nil { | ||
| for i, file := range *e.Files { | ||
| if err := file.Valid(); err != nil { | ||
| return fmt.Errorf("evidence file[%d] invalid: %w", i, err) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Validate Processes if present | ||
| if e.Processes != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for process, may be we are ok to check here as there is not much to check for validity of the process elements.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ok sir |
||
| for i, process := range *e.Processes { | ||
| if process.ProcessName == "" { | ||
| return fmt.Errorf("evidence process[%d] process-name is empty", i) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct implementation is to invoke Method Valid() on the File Object and let File Object, in the file
file.goto implement the Valid Method that can be invoked from line 71. In the Valid for file, check for validity of Mandatory (like FsName) and check for presence of optional elements in the file object. If Optional Elements are present, then please check their validity!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure sir checking it @yogeshbdeshpande