Class: Emasser::ScanFindings
- Inherits:
-
SubCommandBase
- Object
- Thor
- SubCommandBase
- Emasser::ScanFindings
- Defined in:
- lib/emasser/post.rb
Overview
TThe Static Code Scans endpoint provides the ability to upload application scan findings into a system’s assets module.
Application findings can also be cleared from the system.
Endpoint:
/api/systems/{systemId}/static-code-scans - Upload static code scans
Class Method Summary collapse
Instance Method Summary collapse
- #add ⇒ Object
-
#clear ⇒ Object
NOTE: clearFindings is a required parameter to clear an application’s findings, however Thor does not allow a boolean type to be required because it automatically creates a –no-clearFindings option for clearFindings=false.
Methods inherited from SubCommandBase
Methods included from OutputConverters
Methods included from InputConverters
Methods included from OptionsParser
#optional_options, #required_options
Class Method Details
.exit_on_failure? ⇒ Boolean
496 497 498 |
# File 'lib/emasser/post.rb', line 496 def self.exit_on_failure? true end |
Instance Method Details
#add ⇒ Object
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/emasser/post.rb', line 515 def add application = EmassClient::StaticCodeRequiredPostApplication.new application.application_name = [:applicationName] application.version = [:version] application_findings = EmassClient::StaticCodeApplication.new application_findings.code_check_name = [:codeCheckName] application_findings.scan_date = [:scanDate] application_findings.cwe_id = [:cweId] application_findings.raw_severity = [:rawSeverity] if [:rawSeverity] application_findings.count = [:count] if [:count] body = EmassClient::StaticCodeRequiredPost.new body.application = application body.application_findings = application_findings body_array = Array.new(1, body) begin result = EmassClient::StaticCodeScansApi .new.add_static_code_scans_by_system_id(body_array, [:systemId]) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling StaticCodeScansApi->add_static_code_scans_by_system_id'.red puts to_output_hash(e) end end |
#clear ⇒ Object
NOTE: clearFindings is a required parameter to clear an application’s findings, however Thor does not allow a boolean type to be required because it automatically creates a –no-clearFindings option for clearFindings=false
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/emasser/post.rb', line 556 def clear unless [:clearFindings] puts 'To clear an application findings, the field clearFindings (--clearFindings) is required'.red puts NEW_LINE + 'Invoke "bundle exec exe/emasser post scan_findings help clear" for additional help'.yellow exit end application = EmassClient::StaticCodeRequiredPostApplication.new application.application_name = [:applicationName] application.version = [:version] application_findings = EmassClient::StaticCodeApplication.new application_findings.clear_findings = [:clearFindings] body = EmassClient::StaticCodeRequiredPost.new body.application = application body.application_findings = application_findings body_array = Array.new(1, body) begin result = EmassClient::StaticCodeScansApi .new.add_static_code_scans_by_system_id(body_array, [:systemId]) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling StaticCodeScansApi->add_static_code_scans_by_system_id'.red puts to_output_hash(e) end end |