Skip to content

Add security tests for atomic plugin#54

Merged
deacon-mp merged 1 commit intomasterfrom
fix/add-security-tests
Mar 18, 2026
Merged

Add security tests for atomic plugin#54
deacon-mp merged 1 commit intomasterfrom
fix/add-security-tests

Conversation

@deacon-mp
Copy link
Copy Markdown
Contributor

Summary

  • Add tests/test_atomic_security.py with security-focused tests for the atomic plugin
  • Tests verify hashlib.md5() calls in atomic_svc.py include usedforsecurity=False for FIPS compliance
  • Tests validate all atomic test YAML files are parseable and contain required fields (attack_technique, atomic_tests)
  • Tests confirm the payloads directory exists

Test plan

  • Run pytest plugins/atomic/tests/test_atomic_security.py -v from caldera root
  • Failing MD5 test indicates usedforsecurity=False needs to be added to hashlib.md5() calls

Add test_atomic_security.py covering:
- atomic_svc.py: hashlib.md5() calls must use usedforsecurity=False
  for FIPS compliance
- Atomic test YAML files: parseability and required fields validation
  (attack_technique, atomic_tests)
- Payloads directory existence check
@deacon-mp deacon-mp merged commit 2de86b9 into master Mar 18, 2026
1 of 2 checks passed
@deacon-mp deacon-mp deleted the fix/add-security-tests branch March 18, 2026 03:03
@deacon-mp deacon-mp requested a review from Copilot March 18, 2026 03:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new security-focused pytest module to the Atomic plugin test suite, aimed at catching FIPS-incompatible hashlib.md5() usage and validating expected Atomic plugin data/layout.

Changes:

  • Add AST-based test to require usedforsecurity=False on hashlib.md5() calls in atomic_svc.py for FIPS compliance.
  • Add tests to validate Atomic Red Team YAML presence/shape and parseability.
  • Add test asserting the plugin payloads/ directory exists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to +100
def test_yaml_files_exist(self):
"""The atomic data directory should contain YAML test definitions."""
yaml_files = self._get_atomic_yaml_files()
assert len(yaml_files) > 0, (
f"No YAML files found in {ATOMICS_DIR} — "
f"run 'git submodule update --init' to populate data"
)
Comment on lines +46 to +74
def test_md5_calls_use_usedforsecurity_false(self):
"""All hashlib.md5() calls must pass usedforsecurity=False.

On FIPS-enabled systems, hashlib.md5() raises ValueError unless
usedforsecurity=False is explicitly set. Since these hashes are
used for payload naming (not cryptographic security), they should
be annotated accordingly.
"""
md5_calls = self._find_md5_calls()
for call_node in md5_calls:
keyword_names = [kw.arg for kw in call_node.keywords]
has_usedforsecurity = 'usedforsecurity' in keyword_names
if has_usedforsecurity:
for kw in call_node.keywords:
if kw.arg == 'usedforsecurity':
assert (
isinstance(kw.value, ast.Constant)
and kw.value.value is False
), (
f"hashlib.md5() at line {call_node.lineno} has "
f"usedforsecurity set to a non-False value"
)
break
else:
pytest.fail(
f"hashlib.md5() at line {call_node.lineno} in atomic_svc.py "
f"is missing usedforsecurity=False — required for FIPS "
f"compliance"
)
Comment on lines +7 to +11
PLUGIN_DIR = os.path.join(os.path.dirname(__file__), '..')
ATOMIC_SVC_PATH = os.path.join(PLUGIN_DIR, 'app', 'atomic_svc.py')
PAYLOADS_DIR = os.path.join(PLUGIN_DIR, 'payloads')
DATA_DIR = os.path.join(PLUGIN_DIR, 'data')
ATOMICS_DIR = os.path.join(DATA_DIR, 'atomic-red-team', 'atomics')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants