Skip to content

Expose project created date via API#6096

Open
ChrisJr404 wants to merge 1 commit into
DependencyTrack:masterfrom
ChrisJr404:feat/expose-project-created-date-6094
Open

Expose project created date via API#6096
ChrisJr404 wants to merge 1 commit into
DependencyTrack:masterfrom
ChrisJr404:feat/expose-project-created-date-6094

Conversation

@ChrisJr404
Copy link
Copy Markdown

Resolves #6094.

The Project entity did not track a creation timestamp, so GET /api/v1/project/{uuid} had no way to surface when a project was first created. This adds a CREATED column to the PROJECT table and serializes it as created (UNIX epoch milliseconds) on Project responses, matching the existing convention used by lastBomImport and lastVulnerabilityAnalysis.

Changes

  • Project.java: new created field with @Column(name = "CREATED", allowsNull = "true") and @Schema matching the other epoch-millis date fields. Nullable so existing rows are not affected on schema upgrade.
  • ProjectQueryManager#createProject(Project, Collection<Tag>, boolean): stamps created = new Date() if not already set.
  • ProjectQueryManager#clone(...): stamps created on the cloned project (the clone is a new project, so it gets its own creation timestamp rather than inheriting the source's).

No DB migration is included. The column is nullable, so DataNucleus' schema auto-update handles the column add for existing deployments. Existing rows will have created = null until they are next written; this is documented above and behaves the same way lastInheritedRiskScore and similar additive nullable columns have shipped historically (see LAST_RISKSCORE comment in Project.java). If maintainers prefer an explicit backfill via an UpgradeItem, happy to add one.

Tests

  • ProjectQueryManagerTest#testCreateProjectSetsCreatedDate — asserts createProject(...) sets created to the current time.
  • ProjectQueryManagerTest#testCloneProjectSetsCreatedDate — asserts a cloned project gets a fresh created, not the source's.
  • ProjectResourceTest#getProjectByUuidExposesCreatedDateTest — asserts created is present on GET /api/v1/project/{uuid} and is a number within the request window.
  • Existing createProject and patchProject JSON assertions in ProjectResourceTest updated to include "created": "${json-unit.any-number}".

Local: mvn -P enhance test -Dtest='ProjectQueryManagerTest,ProjectResourceTest,ComponentResourceTest,BomResourceTest,BomUploadProcessingTaskTest,WebhookPublisherTest,JiraPublisherTest,ScheduledNotificationDispatchTaskTest' — all 297 tests pass.

DCO

Signed-off-by trailer present on the commit.

Resolves DependencyTrack#6094

Adds a CREATED column to the PROJECT table and exposes it on Project
JSON responses. Existing rows have no creation timestamp recorded;
the column is nullable so backfill is not required.

Signed-off-by: ChrisJr404 <chris@hacknow.com>
@owasp-dt-bot
Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project created date is not available using API call

2 participants