Skip to content

Commit 5e86ef1

Browse files
committed
fix: derive runDuration from assessment timestamps and capture new SDK fields
privateer-sdk v1.24.0 removed `run-duration` in favor of `start`/`end` timestamps; compute the duration locally so the existing column stays populated. Adds the new optional `plan` and `confidence-level` fields to the YAML types so they survive parsing into Redis. Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
1 parent 0f79e0b commit 5e86ef1

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

services/apps/security_best_practices_worker/src/activities/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export async function saveOSPSBaselineInsightsToDB(
132132

133133
const controlEvaluation = await findSuiteControlEvaluation(qx, repo.repoUrl, controlId, suite.id)
134134
for (const assessment of evaluation['assessment-logs']) {
135+
const runDuration = assessment.end
136+
? `${new Date(assessment.end).getTime() - new Date(assessment.start).getTime()}ms`
137+
: ''
135138
await addControlEvaluationAssessment(qx, {
136139
applicability: assessment.applicability,
137140
description: assessment.description,
@@ -141,7 +144,7 @@ export async function saveOSPSBaselineInsightsToDB(
141144
insightsProjectSlug: repo.insightsProjectSlug,
142145
requirementId: assessment.requirement['entry-id'],
143146
result: assessment.result,
144-
runDuration: '',
147+
runDuration,
145148
steps: assessment.steps,
146149
stepsExecuted: assessment['steps-executed'] || 0,
147150
securityInsightsEvaluationId: controlEvaluation.id,

services/apps/security_best_practices_worker/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface ISecurityInsightsPrivateerResultControlEvaluations {
2525

2626
export interface ISecurityInsightsPrivateerResultAssessment {
2727
requirement: { 'reference-id': string; 'entry-id': string }
28+
plan?: { 'reference-id': string; 'entry-id': string }
2829
applicability: string[]
2930
description: string
3031
result: string
@@ -34,6 +35,7 @@ export interface ISecurityInsightsPrivateerResultAssessment {
3435
start: string
3536
end?: string
3637
recommendation?: string
38+
'confidence-level'?: string
3739
}
3840

3941
export interface IUpsertOSPSBaselineSecurityInsightsParams {

0 commit comments

Comments
 (0)