omninode-ai/omnibase_core 52851458622f368c3b596c82bf810bc6acce1d5e
Legitimate Python package with tests
AWS-shaped access key assignmentBasename is uppercase README.md
SHA-2568a16774fb1da66291a0eb9793afa56812b1df7ff0effa6eb01d5a4aa353a0e24
Evidence
1# SPDX-FileCopyrightText: 2025 OmniNode.ai Inc.
2# SPDX-License-Identifier: MIT
3
4"""
5Unit tests for validate-secrets.py validator.
6
7Tests secret detection for:
8- Hardcoded API keys, passwords, tokens
9- Environment variable usage validation
10- Bypass comment handling
11- Various secret pattern detection
12
13SECURITY NOTE:
14This test file intentionally contains realistic-looking secrets (JWT tokens, API keys,
15passwords, co …
19:39… t formats but contain no actual secrets
203. Invalid signatures that cannot be used for authentication
21
22Do NOT replace these with obviously fake values - the validator needs realistic
23patterns to test its detection capabilities.
24"""
25
26import importlib.util
27
28# Import the validator classes
29from pathlib import Path
30
31import pytest
32
33# Load the validator module dynamically (script uses hyphens in filename)
34_validator_path = (
35 Path(__file__).parent.parent.parent.parent
36 / "scripts"
37 / "validation"
38 / "validate-secrets.py"
39)
40_spec = importlib.util.spec_from_file_location("validate_secrets", _validator_path)
41_validator_module = importlib.util.module_from_spec(_spec)
42_spec.loader.exec_module(_validator_module)
43
44PythonSecretValidator = _validator_module.PythonSecretValidator
45SecretValidator = _validator_module.SecretValidator
46
47
48@pytest.mark.unit
49class TestPythonSecretValidator:
50 """Test suite for PythonSecretValidator AST visitor."""
51
52 def test_detects_hardcoded_api_key(self) -> None:
53 """Test detection of hardcoded API key."""
54 code = """
55api_key = "sk-1234567890abcdef"
56"""
57 validator = PythonSecretValidator("test.py")
58 import ast
59
60 tree = ast.parse(code)
61 validator.visit(tree)
62
63 assert len(validator.violations) == 1
64 assert validator.violations[0].secret_name == "api_key"
65 assert validator.violations[0].violation_type == "hardcoded_secret"
66
78:7… assert len(validator.violations) == 1
79 assert validator.violations[0].secret_name == "password"
80
81 def test_detects_hardcoded_token(self) -> None:
82 """Test detection of hardcoded token."""
83 code = """
84auth_token = "Bearer abc123xyz"
85"""
86 validator = PythonSecretValidator("test.py")
87 …
92:7… assert len(validator.violations) == 1
93 assert validator.violations[0].secret_name == "auth_token"
94
95 def test_allows_env_var_access_getenv(self) -> None:
96 """Test that os.getenv() usage is allowed."""
97 code = """
98import os
99api_key = os.getenv("API_KEY")
100password = os.getenv("PASSWORD", "default")
101"""
⋯4 lines
269:17… detection of AWS AKIA format access keys."""
270 code = """
271AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"
272aws_access_key = "AKIAJKLMNOPQRSTUVWXY"
273"""
274 validator = PythonSecretValidator("test.py")
⋯6 lines
Showing the top 5 files — 2 more files (62 regions) not shown.
No evidence locations were recorded for this file. Raw result