Skip to content

Parsing ISO 8601 compliant metadata.timestamp returns null in bom #681

@EilMar

Description

@EilMar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions