Replies: 1 comment
-
|
The STIG Manager API cannot automatically update Reviews at an interval since it is designed to be stateless and does not run scheduled tasks. Also, support for outright deleting Reviews is deliberately very limited, in accordance with NAVSEA requirements, and the Review However, the API does provide an endpoint that would allow you to "reset" a batch of out-of-date Reviews. I'm using "reset" to mean updating a batch of Reviews and setting each It is necessary to create a custom client for this, since the project's Web App currently provides no interface for this endpoint. The client could run as a cronjob/scheduled task once a day. It would send a request to the batch Review editing endpoint ( A complete implementation will need to fetch a valid OIDC access token, but the rest of a JavaScript implementation might then look like: const accessToken = 'token from OP'
const collectionId = 5 // the id of the target collection
const benchmarkIds = ['Google_Chrome_Current_Windows'] // the STIGs to operate on
const maxAgeDays = 30
const minDateStr = new Date(new Date().getTime() - maxAgeDays * 24 * 60 * 60 * 1000).toISOString()
async function resetOldReviews () {
const requestBody = {
action: 'update', // update Reviews, do not create them
source: {
review: { // the common Review that will replace those of the current batch
result: 'notchecked',
detail: '',
comment: '',
status: 'saved'
}
},
assets: {
benchmarkIds // update assets mapped to STIGs in the benchmarkIds array
},
rules: {
benchmarkIds // update rules from any version of STIGs in the benchmarkIds array
},
updateFilters: [ // only update Reviews that match the filter
{
field: 'ts',
condition: 'lessThan',
value: minDateStr
}
],
dryRun: true // set to false when ready to actually change data
}
const response = await fetch(`http://localhost:64001/api/collections/${collectionId}/reviews`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify(requestBody)
})
if (response.ok) {
const data = await response.json()
console.log('Old reviews reset successfully:', data)
} else {
const error = await response.json()
console.error('Failed to reset old reviews:', response.status, response.statusText, error)
}
}
resetOldReviews()
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all! I am running automated Evaluate-STIG scans daily with uploads to STIG Manager using stigman-watcher. My collections have results from over 30 days old, some as in the screenshot show 79 days and 58 days. I am wondering if there is a way to configure STIG Manager to expire/delete results over say 30 days or make it configurable to select the number of days that you desire? If I am uploading daily, I may only want to keep a weeks worth of data for example..
Beta Was this translation helpful? Give feedback.
All reactions