-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce maintenance tasks; Unify cron and lock duration configs for…
… tasks Adds maintenance tasks to help with freeing the database from unwanted bloat: * `ComponentMetadataMaintenanceTask` deletes dangling `IntegrityMetaComponent` and `RepositoryMetaComponent` records, which would otherwise accumulate forever. * `MetricsMaintenanceTask` deletes metrics records older than a configurable retention period (90 days per default). Since the frontend only shows metrics for up to 90 days, it doesn't make sense to keep older data around. Users with longer retention requirements can re-configure this in the UI. * `TagMaintenanceTask` deletes tags that are not used, i.e. not associated with any project, policy, or notification rule. This is particularly useful for organizations that make use of ephemeral, or frequently changing tags. * `VulnerabilityDatabaseMaintenanceTask` deletes `VulnerableSoftware` records that are no longer referenced by any `Vulnerability`. Such orphaned records can happen when vulnerability databases such as the NVD update a vulnerability's affected version ranges, or affected components entirely. The following existing cleanup tasks were renamed accordingly to fit the new maintenance convention: * `VulnerabilityScanCleanupTask` -> `VulnerabilityScanMaintenanceTask` * `WorkflowStateCleanupTask` -> `WorkflowMaintenanceTask` They were additionally refactored to make use of bulk SQL `UPDATE` / `DELETE` statements, rather than modifying individual records via the ORM. This makes them both better performing and more concurrency-friendly. The way how cron and lock duration configuration is retrieved for tasks was refactored to be more uniform. Now, property names align with a task's class name, and follow a predictable structure, voiding the need for separate `ConfigKey` definitions. For example: * `task.cron.metrics.portfolio` -> `task.portfolio.metrics.update.cron` * `task.metrics.portfolio.lockAtMostForInMillis` -> `task.portfolio.metrics.update.lock.max.duration` * `task.metrics.portfolio.lockAtLeastForInMillis` -> `task.portfolio.metrics.update.lock.min.duration` Signed-off-by: nscuro <[email protected]>
- Loading branch information
Showing
50 changed files
with
2,154 additions
and
826 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ain/java/org/dependencytrack/event/maintenance/VulnerabilityDatabaseMaintenanceEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* This file is part of Dependency-Track. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) OWASP Foundation. All Rights Reserved. | ||
*/ | ||
package org.dependencytrack.event.maintenance; | ||
|
||
import alpine.event.framework.Event; | ||
|
||
/** | ||
* @since 5.6.0 | ||
*/ | ||
public class VulnerabilityDatabaseMaintenanceEvent implements Event { | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/dependencytrack/event/maintenance/VulnerabilityScanMaintenanceEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* This file is part of Dependency-Track. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) OWASP Foundation. All Rights Reserved. | ||
*/ | ||
package org.dependencytrack.event.maintenance; | ||
|
||
import alpine.event.framework.Event; | ||
|
||
/** | ||
* @since 5.6.0 | ||
*/ | ||
public class VulnerabilityScanMaintenanceEvent implements Event { | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/dependencytrack/event/maintenance/WorkflowMaintenanceEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* This file is part of Dependency-Track. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) OWASP Foundation. All Rights Reserved. | ||
*/ | ||
package org.dependencytrack.event.maintenance; | ||
|
||
import alpine.event.framework.Event; | ||
|
||
/** | ||
* @since 5.6.0 | ||
*/ | ||
public class WorkflowMaintenanceEvent implements Event { | ||
} |
Oops, something went wrong.