Skip to content

Commit

Permalink
update timestamp only on explicty specified
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Kumar Sahu <vivekkumarsahu650@gmail.com>
  • Loading branch information
viveksahu26 committed Dec 6, 2024
1 parent 0c33df4 commit 05ee179
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
16 changes: 15 additions & 1 deletion pkg/edit/cdx_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,21 @@ func (d *cdxEditDoc) update() {
}

func (d *cdxEditDoc) timeStamp() error {
d.bom.Metadata.Timestamp = utcNowTime()
if !d.c.shouldTimeStamp() {
return errNoConfiguration
}

if d.c.search.subject != "document" {
return errNotSupported
}

if d.c.onMissing() {
if d.bom.Metadata.Timestamp == "" {
d.bom.Metadata.Timestamp = utcNowTime()
}
} else {
d.bom.Metadata.Timestamp = utcNowTime()
}
return nil
}

Expand Down
23 changes: 20 additions & 3 deletions pkg/edit/spdx_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,29 @@ func (d *spdxEditDoc) typ() error {
}

func (d *spdxEditDoc) timeStamp() error {
if d.bom.CreationInfo == nil {
d.bom.CreationInfo = &spdx.CreationInfo{}
if !d.c.shouldTimeStamp() {
return errNoConfiguration
}

d.bom.CreationInfo.Created = utcNowTime()
if d.c.search.subject != "document" {
return errNotSupported
}

if d.c.onMissing() {
if d.bom.CreationInfo == nil {
d.bom.CreationInfo = &spdx.CreationInfo{}
}

if d.bom.CreationInfo.Created == "" {
d.bom.CreationInfo.Created = utcNowTime()
}
} else {
if d.bom.CreationInfo == nil {
d.bom.CreationInfo = &spdx.CreationInfo{}
}

d.bom.CreationInfo.Created = utcNowTime()
}
return nil
}

Expand Down

0 comments on commit 05ee179

Please sign in to comment.