Class: AiRootShield::CiCd::SecurityTestModule
- Inherits:
-
Object
- Object
- AiRootShield::CiCd::SecurityTestModule
- Defined in:
- lib/ai_root_shield/ci_cd/security_test_module.rb
Overview
CI/CD integration security testing module
Constant Summary collapse
- SUPPORTED_PLATFORMS =
Supported CI/CD platforms
%w[ github_actions gitlab_ci jenkins azure_devops circleci travis_ci bitbucket_pipelines ].freeze
- TEST_STATUSES =
Test result statuses
{ passed: 'PASSED', failed: 'FAILED', warning: 'WARNING', skipped: 'SKIPPED', error: 'ERROR' }.freeze
Instance Method Summary collapse
-
#generate_ci_config(platform, options = {}) ⇒ Object
Generate CI/CD configuration for specific platform.
-
#initialize(config = {}) ⇒ SecurityTestModule
constructor
A new instance of SecurityTestModule.
-
#run_security_tests(device_logs_path, options = {}) ⇒ Object
Run comprehensive security tests for CI/CD pipeline.
Constructor Details
#initialize(config = {}) ⇒ SecurityTestModule
Returns a new instance of SecurityTestModule.
31 32 33 34 35 36 37 38 |
# File 'lib/ai_root_shield/ci_cd/security_test_module.rb', line 31 def initialize(config = {}) @config = config @test_results = [] @artifacts_path = config[:artifacts_path] || './security_test_artifacts' @report_format = config[:report_format] || 'json' @fail_on_high_risk = config[:fail_on_high_risk] || true @risk_threshold = config[:risk_threshold] || 70 end |
Instance Method Details
#generate_ci_config(platform, options = {}) ⇒ Object
Generate CI/CD configuration for specific platform
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ai_root_shield/ci_cd/security_test_module.rb', line 88 def generate_ci_config(platform, = {}) case platform.to_s.downcase when 'github', 'github_actions' generate_github_actions_config() when 'gitlab', 'gitlab_ci' generate_gitlab_ci_config() when 'jenkins' generate_jenkins_config() when 'azure', 'azure_devops' generate_azure_devops_config() when 'circleci' generate_circleci_config() else raise "Unsupported CI/CD platform: #{platform}" end end |
#run_security_tests(device_logs_path, options = {}) ⇒ Object
Run comprehensive security tests for CI/CD pipeline
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ai_root_shield/ci_cd/security_test_module.rb', line 41 def run_security_tests(device_logs_path, = {}) setup_test_environment test_suite = { metadata: (), test_results: [], summary: {}, artifacts: [] } begin # Load device logs device_logs = load_device_logs(device_logs_path) # Run platform-specific tests if device_logs['platform'] == 'android' test_suite[:test_results] << run_android_security_tests(device_logs) elsif device_logs['platform'] == 'ios' test_suite[:test_results] << run_ios_security_tests(device_logs) else test_suite[:test_results] << run_generic_security_tests(device_logs) end # Run cross-platform tests test_suite[:test_results] << run_cross_platform_tests(device_logs) # Generate test summary test_suite[:summary] = generate_test_summary(test_suite[:test_results]) # Generate artifacts test_suite[:artifacts] = generate_test_artifacts(test_suite) # Determine pipeline result pipeline_result = determine_pipeline_result(test_suite[:summary]) test_suite[:pipeline_result] = pipeline_result # Export results export_test_results(test_suite) test_suite rescue StandardError => e handle_test_error(e, test_suite) end end |