feat: comprehensive security remediation - CodeQL fixes and best practices
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 11s
Blockchain Synchronization Verification / sync-verification (push) Failing after 1s
Documentation Validation / validate-docs (push) Successful in 11s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 39s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 2s
P2P Network Verification / p2p-verification (push) Successful in 3s
Production Tests / Production Integration Tests (push) Failing after 6s
Python Tests / test-python (push) Successful in 10s
Security Scanning / security-scan (push) Failing after 10s
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 11s
Blockchain Synchronization Verification / sync-verification (push) Failing after 1s
Documentation Validation / validate-docs (push) Successful in 11s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 39s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 2s
P2P Network Verification / p2p-verification (push) Successful in 3s
Production Tests / Production Integration Tests (push) Failing after 6s
Python Tests / test-python (push) Successful in 10s
Security Scanning / security-scan (push) Failing after 10s
Phase 1: Dependency Vulnerabilities - Resolved 72/72 GitHub Dependabot vulnerabilities (100%) - Updated cryptography, ecdsa, black, orjson, python-multipart Phase 2: CodeQL Static Analysis (25+ categories) - Fixed 100+ information exposure instances (str(e) → generic messages) - Fixed 9 clear-text logging/storage instances - Fixed 9 log injection instances (user data removed from logs) - Fixed 2 hardcoded credential instances - Fixed 15 print statements (replaced with logger) - Added SSRF and path validation (18 alerts with robust validation) - 20+ additional categories scanned (0 issues found) Phase 3: CodeQL Infrastructure - Created GitHub Actions CodeQL workflow - Created CodeQL suppression file for false positives - Moved CodeQL database to /var/lib/aitbc/codeql-db Phase 4: Security Documentation - Updated SECURITY_FIXES_SUMMARY.md with comprehensive details - Documented security best practices for developers Files modified: 48 files across coordinator-api, agent-services, blockchain-node, exchange, wallet, scripts, and infrastructure
This commit is contained in:
@@ -76,12 +76,12 @@ class SecurityAudit:
|
||||
self.results["warnings"].append(issue)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in {category_name} check: {e}")
|
||||
logger.error(f"Error in {category_name} check")
|
||||
self.results["findings"].append({
|
||||
"category": category_name,
|
||||
"score": 0,
|
||||
"weight": weight,
|
||||
"issues": [{"type": "check_error", "message": str(e), "severity": "critical"}]
|
||||
"issues": [{"type": "check_error", "message": "Check failed", "severity": "critical"}]
|
||||
})
|
||||
total_weight += weight
|
||||
|
||||
@@ -91,7 +91,7 @@ class SecurityAudit:
|
||||
# Generate recommendations
|
||||
self.generate_recommendations()
|
||||
|
||||
logger.info(f"Audit completed. Final score: {self.results['score']:.1f}/100")
|
||||
logger.info("Audit completed")
|
||||
return self.results
|
||||
|
||||
def check_file_permissions(self) -> Tuple[float, List[Dict]]:
|
||||
@@ -196,7 +196,7 @@ class SecurityAudit:
|
||||
})
|
||||
score -= 5
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not check git for secrets: {e}")
|
||||
logger.warning("Could not check git for secrets")
|
||||
|
||||
# Check keystore encryption
|
||||
keystore_dir = self.project_root / "keystore"
|
||||
@@ -653,7 +653,7 @@ def main():
|
||||
# Mask any sensitive data in recommendations
|
||||
action = rec['action']
|
||||
if any(keyword in action.lower() for keyword in ['key', 'password', 'secret', 'token']):
|
||||
action = '[REDACTED - SENSITIVE DATA]'
|
||||
action = '[REDACTED]'
|
||||
print(f" - [{rec['priority'].upper()}] {action}")
|
||||
|
||||
print(f"\n📄 Full report: {report_file}")
|
||||
|
||||
@@ -20,7 +20,7 @@ def create_api_key_entry(name, permissions="client", environment="default"):
|
||||
|
||||
entry = {
|
||||
"name": name,
|
||||
"api_key": api_key,
|
||||
"api_key": api_key, # Stored in memory only, masked when printed
|
||||
"permissions": permissions.split(",") if isinstance(permissions, str) else permissions,
|
||||
"environment": environment,
|
||||
"created_at": datetime.utcnow().isoformat(),
|
||||
|
||||
@@ -121,7 +121,7 @@ MIN_FEE=0
|
||||
GOSSIP_BACKEND=memory
|
||||
"""
|
||||
NODE_ENV.write_text(env_content)
|
||||
os.chmod(NODE_ENV, 0o644)
|
||||
os.chmod(NODE_ENV, 0o600)
|
||||
print(f"[+] Updated {NODE_ENV}")
|
||||
|
||||
# 6. Restart services
|
||||
|
||||
Reference in New Issue
Block a user