2525#define RECIPE_JSON "Json"
2626#define RECIPE_STATUS "ExpectedResult"
2727#define RECIPE_WAIT_SECONDS "WaitSeconds"
28+ #define SECURITY_BASELINE "SecurityBaseline"
2829
2930#define RECIPE_RUN_COMMAND "RunCommand"
3031
@@ -382,13 +383,25 @@ int RunCommand(const COMMAND_STEP* command)
382383
383384int RunTestStep (const TEST_STEP * test , const MANAGEMENT_MODULE * module )
384385{
385- int result = 0 ;
386+ const char * skippedAudits [] = {
387+ "auditEnsureKernelSupportForCpuNx" ,
388+ "auditEnsureDefaultDenyFirewallPolicyIsSet" ,
389+ "auditEnsureAuthenticationRequiredForSingleUserMode" ,
390+ "auditEnsureAllBootloadersHavePasswordProtectionEnabled"
391+ };
392+ int numSkippedAudits = ARRAY_SIZE (skippedAudits );
393+
394+ const char * audit = "audit" ;
395+ const char * reason = NULL ;
386396 JSON_Value * actualJsonValue = NULL ;
387397 JSON_Value * expectedJsonValue = NULL ;
388398 MMI_JSON_STRING payload = NULL ;
389399 char * payloadString = NULL ;
400+ bool asbAudit = false;
390401 int payloadSize = 0 ;
402+ int i = 0 ;
391403 int mmiStatus = 0 ;
404+ int result = 0 ;
392405
393406 if (test == NULL )
394407 {
@@ -418,36 +431,72 @@ int RunTestStep(const TEST_STEP* test, const MANAGEMENT_MODULE* module)
418431 LOG_ERROR ("Failed to parse JSON payload: %s" , payloadString );
419432 result = EINVAL ;
420433 }
434+ else if ((0 == strcmp (test -> component , SECURITY_BASELINE )) &&
435+ (0 == strncmp (test -> object , audit , strlen (audit ))))
436+ {
437+ asbAudit = true;
438+
439+ for (i = 0 ; i < numSkippedAudits ; i ++ )
440+ {
441+ if (0 == strcmp (test -> object , skippedAudits [i ]))
442+ {
443+ asbAudit = false;
444+ break ;
445+ }
446+ }
447+ }
421448 }
422449 }
423450
424- if (test -> payload != NULL )
451+ if (test -> payload || asbAudit )
425452 {
426- if (actualJsonValue != NULL )
453+ if (asbAudit )
454+ {
455+ if (NULL == (reason = json_value_get_string (actualJsonValue )))
456+ {
457+ LOG_ERROR ("Assertion failed, json_value_get_string('%s') failed" , json_serialize_to_string (actualJsonValue ));
458+ result = -1 ;
459+ }
460+ else if (0 != strncmp (reason , SECURITY_AUDIT_PASS , strlen (SECURITY_AUDIT_PASS )))
461+ {
462+ LOG_ERROR ("Assertion failed, expected: '%s...', actual: '%s'" , SECURITY_AUDIT_PASS , reason );
463+ result = EFAULT ;
464+ }
465+ else
466+ {
467+ LOG_INFO ("Assertion passed with reason: '%s'" , reason + strlen (SECURITY_AUDIT_PASS ));
468+ }
469+ }
470+ else if (actualJsonValue != NULL )
427471 {
428472 if (NULL == (expectedJsonValue = json_parse_string (test -> payload )))
429473 {
430474 LOG_ERROR ("Failed to parse expected JSON payload: %s" , test -> payload );
431- result = EINVAL ;
475+ result = EFAULT ;
432476 }
433- else if (! json_value_equals (expectedJsonValue , actualJsonValue ))
477+ else if (0 == json_value_equals (expectedJsonValue , actualJsonValue ))
434478 {
435- LOG_ERROR ("Assertion failed, expected: '%s', actual: '%s'" , json_serialize_to_string (expectedJsonValue ), json_serialize_to_string (actualJsonValue ));
436- result = -1 ;
479+ LOG_ERROR ("Assertion failed, expected: '%s', actual: '%s'" ,
480+ json_serialize_to_string (expectedJsonValue ), json_serialize_to_string (actualJsonValue ));
481+ result = EFAULT ;
437482 }
438483 }
439484 else
440485 {
441486 LOG_ERROR ("Assertion failed, expected: '%s', actual: (null)" , test -> payload );
442- result = -1 ;
487+ result = EFAULT ;
443488 }
444489 }
445490
446491 if (test -> status != mmiStatus )
447492 {
448493 LOG_ERROR ("Assertion failed, expected result '%d', actual '%d'" , test -> status , mmiStatus );
449- result = -1 ;
494+ result = EFAULT ;
450495 }
496+
497+ json_value_free (expectedJsonValue );
498+ json_value_free (actualJsonValue );
499+ FREE_MEMORY (payloadString );
451500 }
452501 else if (test -> type == DESIRED )
453502 {
@@ -456,7 +505,7 @@ int RunTestStep(const TEST_STEP* test, const MANAGEMENT_MODULE* module)
456505 if (test -> status != mmiStatus )
457506 {
458507 LOG_ERROR ("Assertion failed, expected result '%d', actual '%d'" , test -> status , mmiStatus );
459- result = -1 ;
508+ result = EFAULT ;
460509 }
461510 }
462511 else
0 commit comments