Parsing ISO 8601 compliant metadata.timestamp returns null in bom

Open Beginner friendly
#681 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
data

Research direction

Start with org.cyclonedx.parsers.JsonParser and the BomParserTest reproduction, using src/test/resources/bom.json from the attached TestSbomImport. Compare parsing behavior after 9.1.0 and verify that an ISO 8601 metadata.timestamp produces a non-null Bom metadata timestamp; keep the regression test passing.

Written by the indexing model from the issue text.

Description

Parsing a bom with ISO 8601 compliant available metadata.timestamp using a version > 9.1.0 returns a bom object with value null
for metadata.timestamp.

Code to reproduce the behaviour (or run the test in BomParserTest in attached TestSbomImport):

import org.cyclonedx.model.Bom;
import org.cyclonedx.parsers.JsonParser;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

public class BomParserTest {
  @Test
  void manTest() {
    try {
      String bomContent = new String(Files.readAllBytes(new File("src/test/resources/bom.json").toPath()));
      Bom b = new JsonParser().parse(bomContent.getBytes(StandardCharsets.UTF_8));
      // works with 9.1.0 but not with later versions
      assertNotNull(b.getMetadata().getTimestamp());
    }
    catch (Exception e) {
      assertNull(e);
    }
  }
}

TestSbomImport.zip

Dominant language
Java
Stars
120
Forks
91
Avg merge
10h 17m
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CycloneDX/cyclonedx-core-java

All issues in CycloneDX/cyclonedx-core-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.