-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-calculate historical risk score #789
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: leec94 <[email protected]>
Signed-off-by: leec94 <[email protected]>
Signed-off-by: leec94 <[email protected]>
Can you share some more details on the issues you're encountering? What are you trying, and is pgadmin showing any errors?
I'll try to provide some guidance below. In general I think the whole thing becomes easier if you don't use a stored procedure for this. The SQL you already have: UPDATE "DEPENDENCYMETRICS" SET "v_risk_score" = "CALC_RISK_SCORE"("v_critical", "v_high", "v_medium", "v_low", "v_unassigned"); can be rewritten to the following: UPDATE "DEPENDENCYMETRICS"
SET "RISK_SCORE" = "CALC_RISK_SCORE"("CRITICAL", "HIGH", "MEDIUM", "LOW", "UNASSIGNED_SEVERITY") There is no need to declare any input or output variables, the RDBMS will execute the above as-is, and update the risk score of all records in the As for how to execute the query, the main way we interact with the database now is via JDBI. It should also "just work" in pgadmin, provided you have data in your There are multiple ways to use JDBI, but the fluent API is probably the easiest. You can find an example here: hyades-apiserver/src/test/java/org/dependencytrack/resources/v1/AnalysisResourceTest.java Lines 808 to 820 in f36392b
(Ignore the query in the example above, just want to showcase how to use I personally find that working on something like this is easiest in a test-driven way:
You can take inspiration from the existing metrics update tests.
Add this as a check to the new
See above. Getting tests set up will help you in developing the feature. Let me know if you need more help with that. |
Description
Related to DependencyTrack/dependency-track#2824 , this issue is to allow the custom weights of risk scores to be re-calculated.
Addressed Issue
Related to DependencyTrack/dependency-track#2824
Front end issue to go along with this is DependencyTrack/hyades-frontend#94
Additional Details
Adds a new endpoint to tell the database to recalculate with
/riskscore/refresh
. If there's a better approach for this, I'm all ears!This PR is draft, I have a few questions / open ended items:
DEPENDENCYMETRICS
table. I have pgadmin set up and connected to the hyades database, but i'm unable to run a query of the sql as it is, or even just the "update" part.weight.history.enabled
is True, don't run this when false. Where would this logic be done?Checklist