Skip to content

Call security context validators during action-set validation#190

Closed
resolvicomai wants to merge 1 commit into
NASA-AMMOS:mainfrom
resolvicomai:fix/security-context-validation-callbacks
Closed

Call security context validators during action-set validation#190
resolvicomai wants to merge 1 commit into
NASA-AMMOS:mainfrom
resolvicomai:fix/security-context-validation-callbacks

Conversation

@resolvicomai
Copy link
Copy Markdown

Summary

  • iterate through security actions and security operations in BSL_SecCtx_ValidatePolicyActionSet
  • dispatch validation to the registered security context descriptor for each operation
  • preserve the current default BIB/BCB permissive behavior until their validators implement deeper checks
  • add a regression test proving a registered validator is called and its failure is propagated

Closes #184.

Validation

  • git diff --check
  • clang-format --style=file -i src/backend/SecurityContext.c src/security_context/BIB_HMAC_SHA2.c test/test_BackendSecurityContext.c
  • ./build.sh deps
  • ./build.sh prep -DBUILD_DOCS_API=OFF -DBUILD_DOCS_MAN=OFF -DBUILD_UNITTEST=ON -DBUILD_COVERAGE=OFF -DTEST_MEMCHECK=OFF
  • cmake --build build/default --target src/CMakeFiles/bsl_dynamic.dir/backend/SecurityContext.c.o
  • cmake --build build/default --target src/CMakeFiles/bsl_default_sc.dir/security_context/BIB_HMAC_SHA2.c.o
  • syntax-checked test/test_BackendSecurityContext.c with the generated CMake compile flags

Full local ./build.sh/test execution is blocked on macOS by existing unrelated build issues: tv_usec format warnings promoted to errors, missing OpenSSL include path for bsl_crypto, and unresolved bsl_front symbols. The modified production objects and new test source compile/syntax-check locally; CI should exercise the Linux matrix.

@resolvicomai resolvicomai requested a review from a team as a code owner May 21, 2026 11:39
@github-project-automation github-project-automation Bot moved this to Todo in BSL May 21, 2026
(void)lib;
(void)bundle;
(void)action_set;
if (lib == NULL || bundle == NULL || action_set == NULL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using the BSL_CHKFALSE macro, E.g. BSL_CHKFALSE(NULL != lib), etc.

return lib != NULL && bundle != NULL && sec_oper != NULL;
}

bool BSLX_BCB_Validate(BSL_LibCtx_t *lib, const BSL_BundleRef_t *bundle, const BSL_SecOper_t *sec_oper)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR did not introduce this issue, but this function should be moved to BCB_AES_GCM.c

TEST_ASSERT_FALSE(
BSL_SecCtx_ValidatePolicyActionSet(&LocalTestCtx.bsl, &LocalTestCtx.mock_bpa_ctr.bundle_ref, &action_set));
TEST_ASSERT_EQUAL_UINT(1, TestSecCtxValidateCallCount);
TEST_ASSERT_EQUAL_UINT64(1, TestSecCtxValidatedTarget);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestSecCtxValidateResult seemingly unused / unverified after being set to false at top of the function.

TEST_ASSERT_EQUAL(0, BSL_TestContext_Deinit(&LocalTestCtx));
}

void test_SecurityContext_ValidatePolicyActionSet_UsesRegisteredValidator(void)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does properly verify changes! I think the scope of this could be increased for sec ctx execute too since such a test does not exist. As in, verify BSL_TestSecCtx_Execute with the call count & target as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That case is essentially already exercised by the rest of the tests in this file, but I think an explicit simple test is still useful while we're at it with this one.

@github-project-automation github-project-automation Bot moved this from Todo to Done in BSL May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Call security context validate functions in backend security context implementation

2 participants