Add the check condition to SCA stored data#3631
Conversation
| "check.rationale": { | ||
| "type": "text" | ||
| }, | ||
| "check.condition": { |
There was a problem hiding this comment.
This field is inside the oscap block, it has no relation to SCA but the integration with OpenSCAP.
| "check.rationale": { | ||
| "type": "text" | ||
| }, | ||
| "check.condition": { |
There was a problem hiding this comment.
This field is inside the oscap block, it has no relation to SCA but the integration with OpenSCAP.
a4cbe0d to
72247dd
Compare
99eb124 to
49dd356
Compare
| "remediation": { | ||
| "type": "keyword" | ||
| }, | ||
| "condition": { |
There was a problem hiding this comment.
Remove this field from the template as well.
| } | ||
| } | ||
| }, | ||
| "condition": { |
There was a problem hiding this comment.
Remove this field from the template, the condition field won't be shown as an alert field, same as rule.
| cJSON **policy_id, cJSON **command, cJSON **rules); | ||
| static int CheckPoliciesJSON(cJSON *event, cJSON **policies); | ||
| static int CheckDumpJSON(cJSON *event, cJSON **elements_sent, cJSON **policy_id, cJSON **scan_id); | ||
| static void FillCheckEventInfo(Eventinfo *lf, cJSON *scan_id, cJSON *id, cJSON *name, cJSON *title, cJSON *description, |
There was a problem hiding this comment.
Don't add condition to the alert. So, it is not needed to pass it to this function.
| if (result){ | ||
| if(strcmp(wdb_response,result->valuestring)) { | ||
| FillCheckEventInfo(lf,scan_id,id,name,title,description,rationale,remediation,compliance,reference,file,directory,process,registry,result,status,reason,wdb_response,command); | ||
| FillCheckEventInfo(lf, scan_id, id,name, title, description, rationale, remediation, |
There was a problem hiding this comment.
Same as above, remove condition from this call.
| } else if (status && status->valuestring) { | ||
| if(strcmp(wdb_response, status->valuestring)) { | ||
| FillCheckEventInfo(lf,scan_id,id,name,title,description,rationale,remediation,compliance,reference,file,directory,process,registry,result,status,reason,wdb_response,command); | ||
| FillCheckEventInfo(lf, scan_id, id,name, title, description, rationale, remediation, |
There was a problem hiding this comment.
Same as above, remove condition from this call.
| if (result) { | ||
| if(strcmp(wdb_response,result->valuestring)) { | ||
| FillCheckEventInfo(lf,scan_id,id,name,title,description,rationale,remediation,compliance,reference,file,directory,process,registry,result,status,reason,NULL,command); | ||
| FillCheckEventInfo(lf, scan_id, id, name, title, description, rationale, remediation, |
There was a problem hiding this comment.
Same as above, remove condition from this call.
| } else if (status && status->valuestring) { | ||
| if(strcmp(wdb_response, status->valuestring)) { | ||
| FillCheckEventInfo(lf,scan_id,id,name,title,description,rationale,remediation,compliance,reference,file,directory,process,registry,result,status,reason,NULL,command); | ||
| FillCheckEventInfo(lf, scan_id, id, name, title, description, rationale, |
There was a problem hiding this comment.
Same as above, remove condition from this call.
| } | ||
|
|
||
| static void FillCheckEventInfo(Eventinfo *lf,cJSON *scan_id,cJSON *id,cJSON *name,cJSON *title,cJSON *description,cJSON *rationale,cJSON *remediation,cJSON *compliance,cJSON *reference,cJSON *file,cJSON *directory,cJSON *process,cJSON *registry,cJSON *result,cJSON *status,cJSON *reason,char *old_result,cJSON *command) { | ||
| static void FillCheckEventInfo(Eventinfo *lf, cJSON *scan_id, cJSON *id, cJSON *name, cJSON *title, cJSON *description, |
There was a problem hiding this comment.
Same as above, remove condition from this call.
| } | ||
|
|
||
| if (condition){ | ||
| fillData(lf, "sca.check.condition", condition->valuestring); |
There was a problem hiding this comment.
Don't call fillData() for condition. It only has to be added to the DB.

Description
The purpose of this PR is that the field
conditionof the module sca, should be stored in the database.Tests
No error found with scan-build
No error found with address-sanitizer
Custom tests
conditionis show in the databaseNow, in the database show the following message:
conditionis shown when we upgrade the manager and the agent.First, we obtain a message output from the database of version 3.9.
Upgrade the manager and check the message. We can see that the field
conditionis now visible.Connect an agent with the version 3.9 and, check if the field ´condition´ is shown.
The space to the field is empty, now upgrade the agent, and check if the database has been updated.