snyk-tech-services / snyk2spdx

Other
14 stars 8 forks source link

[🐛] Wrong date is assigned to creation of SPDX result #54

Open bsoroushian opened 5 months ago

bsoroushian commented 5 months ago

Expected behaviour

A valid date be attributed to the resulting SPDX report

Actual behaviour

An Invalid date with month 0 was assigned to the SPDX report

Steps to reproduce

Scan any arbitrary image and convert its result using snyk2spdx.

Debug log

{
  "id": "SPDXRef-docker-image|dev....",
  "specVersion": "SPDX-3.0",
  "creator": "Organization: Snyk Ltd",
  "created": "2024-00-02T20:01:35Z",
  "profile": [
    "base",
    "vulnerabilities"
  ],
  "description": "Snyk test result for project docker-image|dev.registry....-my-apps in SPDX SBOM format",

The function getDate() in generate-date.ts uses d.getMonth().toString() which is converting a zero-based number to string therefore in January date is zero. The day also would be wrong since d.getDay() will return a number between 0 and 6 (0 for Sunday and 6 for Saturday). Alternative would be to use date.toISOString().

Screenshots

If applicable, add screenshots to help explain your problem.