module SastBox::Cwe
Constants
- ACTIVE_DEBUG_CODE
- AUTHORIZATION_BYPASS_THROUGH_KEY
- BASIC_XSS
- BROKEN_CRYPTO
- CLEARTEXT_STORAGE_OF_SENSITIVE_INFORMATION
- CLEARTEXT_TRANSMISSION
- CODE_INJECTION
- CSRF
- DATA_LEAK_BETWEEN_SESSIONS
- DESERIALIZATION_OF_UNTRUSTED_DATA
- DIVIDE_BY_ZERO
- DOWNLOAD_OF_CODE_WITHOUT_INTEGRITY_CHECK
- ERROR_CONDITION_WITHOUT_ACTION
- ERROR_CONTAINING_SENSITIVE_INFO
- EVAL_INJECTION
- EXPOSED_DANGEROUS_METHOD_OR_FUNCTION
- EXPOSURE_OF_SYSTEM_DATA
- EXPOSURE_RESOURCE_WRONG_SPHERE
- EXPOSURE_SENSITIVE_INFO
- EXTERNAL_CONTROL_FILE_NAME
- HARD_CODED_PASSWORD
- IMPROPER_ACCESS_CONTROL
- IMPROPER_AUTHENTICATION
- IMPROPER_AUTHORIZATION
- IMPROPER_CERT_VALIDATION
- IMPROPER_CHECK_OF_EXCEPT_COND
- IMPROPER_CONTROL_DYNAMIC_ATTR
- IMPROPER_INPUT_VALIDATION
- IMPROPER_RESOURCE_SHUTDOWN_OR_RELEASE
- IMPROPER_RESTRICTION_MEMORY_BOUNDS
- IMPROPER_RESTRICTION_OF_RENDERED_UI_LAYERS_OF_FRAMES
- IMPROPER_RESTRICTION_OF_XML_EXTERNAL_ENTITY_REFERENCE
- IMPROPER_VERIFICATION_OF_SIGNATURE
- IMPROPER_WILDCARD_NEUTRALIZATION
- INADEQUATE_ENCRYPTION_STRENGTH
- INCLUSION_FUNCTIONALITY_UNTRUSTED_SPHERE
- INCORRECT_PERMISSION_ASSIGNMENT
- INCORRECT_REGEX
- INSECURE_TEMP_FILE
- INSUFFICIENT_ENTROPY
- INSUFFICIENT_RANDOM_VALUES
- INTEGER_OVERFLOW
- LDAP_INJECTION
- MULTIPLE_BINDS
- NULL_POINTER_DEREFERENCE
- OBSOLETE_FUNCTION
- OPEN_REDIRECT
- OS_COMMAND_INJECTION
- PATH_TRAVERSAL
- PHP_REMOTE_FILE_INCLUSION
- PROTECTION_MECHANISM_FAILURE
- REGEX_WITHOUT_ANCHORS
- RELIANCE_ON_UNTRUSTED_INPUTS_IN_A_SECURITY_DECISION
- RESOURCE_CONSUMPTION
- RESPONSE_SPLITTING
- SECURITY_MISCONFIGURATION
- SELECTION_OF_LESS_SECURE_ALGORITHM_DURING_NEGOTIATION
- SENSITIVE_COOKIE_WITHOUT_HTTPONLY_FLAG
- SENSITIVE_INFO_IN_SOURCE_CODE_COMMENTS
- SENSITIVE_INFO_LOG_FILE
- SESSION_FIXATION
- SQL_INJECTION
- SSRF
- SUSPICIOUS_COMMENT
- TIMING_DISCREPANCY
- TOCTOU
- UNDEF
- UNINITIALIZED_VARIABLE
- UNPROTECTED_STORAGE_OF_CREDENTIALS
- UNRESTRICTED_UPLOAD_OF_FILE_WITH_DANGEROUS_TYPE
- UNSAFE_REFLECTION
- UNSALTED_ONE_WAY_HASH
- USE_OF_EXTERNALLY_CONTROLLED_FORMAT_STRING
- USE_OF_PERSISTENT_COOKIES
- USE_OF_POTENTIALLY_DANGEROUS_FUNCTION
- USE_OF_UNMAINTAINED_THIRD_PARTY_COMPONENTS
- USE_OF_WEB_LINK_TO_UNTRUSTED_TARGET
- USING_COMPONENTS_WITH_KNOWN_VULNERABILITIES
- WEAK_PASSWORD_REQUIREMENT
- WEAK_PRNG
- XPATH_INJECTION
- XQUERY_INJECTION
- XSS
Public Instance Methods
alternative_titles(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 182 def alternative_titles(issue) @alternative_titles = Set.new @alternative_titles << issue[:title].downcase @alternative_titles << @alternative_titles.first.split('_').join(' ') @alternative_titles << @alternative_titles.first.split('-').join(' ') @alternative_titles << @alternative_titles.first.gsub("hard coded", "hard-coded") @alternative_titles << @alternative_titles.first.gsub("hardcoded", "hard-coded") @alternative_titles end
cwe_found?(issue, patterns, cwe)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 6 def cwe_found?(issue, patterns, cwe) patterns.each do |pattern| @alternative_titles.each do |title| if title.include? pattern issue[:cwe_id] = cwe return true end end end return false end
cwe_start_heuristics(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 162 def cwe_start_heuristics(issue) alternative_titles(issue) issue[:cwe_id] = SastBox::Cwe::UNDEF return if detected_sql_injection?(issue) return if detected_xss?(issue) return if detected_cmd_injection?(issue) return if detected_code_injection?(issue) return if detected_session_fixation?(issue) return if detected_csrf?(issue) return if detected_deserialization?(issue) return if detected_path_traversal?(issue) return if detected_hardcoded_password?(issue) return if detected_null_ptr_deref?(issue) return if detected_broken_crypto?(issue) return if detected_improper_authorization?(issue) return if detected_improper_authentication?(issue) return if detected_improper_input_validation?(issue) return if detected_unrestricted_file_upload?(issue) end
detected_broken_crypto?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 112 def detected_broken_crypto?(issue) patterns = [ 'weak cipher', 'weak crypto', 'insecure cipher', 'insecure crypto', 'insecure encryption', 'broken cipher', 'broken crypto', 'weak hash', 'insecure hash', 'broken hash', ] cwe_found?(issue, patterns, SastBox::Cwe::BROKEN_CRYPTO) end
detected_cmd_injection?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 38 def detected_cmd_injection?(issue) patterns = [ 'command injection', 'command execution', 'cmd injection', 'cmd execution', 'cmd exec', 'shell injection', 'shell metacharacters' ] cwe_found?(issue, patterns, SastBox::Cwe::OS_COMMAND_INJECTION) end
detected_code_injection?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 51 def detected_code_injection?(issue) patterns = [ 'code injection', 'code execution', 'code exec', 'code inj' ] cwe_found?(issue, patterns, SastBox::Cwe::CODE_INJECTION) end
detected_csrf?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 68 def detected_csrf?(issue) patterns = [ 'csrf', 'xsrf', 'cross site request forgery', 'session riding', 'cross site reference forgery', ] cwe_found?(issue, patterns, SastBox::Cwe::CSRF) end
detected_deserialization?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 79 def detected_deserialization?(issue) patterns = [ 'deserializ', 'unmarshaling', 'unpickling', 'php object injection' ] cwe_found?(issue, patterns, SastBox::Cwe::DESERIALIZATION_OF_UNTRUSTED_DATA) end
detected_hardcoded_password?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 98 def detected_hardcoded_password?(issue) patterns = [ 'hard-coded' ] cwe_found?(issue, patterns, SastBox::Cwe::HARD_CODED_PASSWORD) end
detected_improper_authentication?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 137 def detected_improper_authentication?(issue) patterns = [ 'improper authentication', 'no authentication', 'broken authentication', ] cwe_found?(issue, patterns, SastBox::Cwe::IMPROPER_AUTHENTICATION) end
detected_improper_input_validation?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 146 def detected_improper_input_validation?(issue) patterns = [ 'input validation', 'data validation', ] cwe_found?(issue, patterns, SastBox::Cwe::IMPROPER_INPUT_VALIDATION) end
detected_null_ptr_deref?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 105 def detected_null_ptr_deref?(issue) patterns = [ 'null pointer deref' ] cwe_found?(issue, patterns, SastBox::Cwe::NULL_POINTER_DEREFERENCE) end
detected_path_traversal?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 89 def detected_path_traversal?(issue) patterns = [ 'path traversal', 'traversal', 'pathtraversal' ] cwe_found?(issue, patterns, SastBox::Cwe::PATH_TRAVERSAL) end
detected_session_fixation?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 61 def detected_session_fixation?(issue) patterns = [ 'session fixation', ] cwe_found?(issue, patterns, SastBox::Cwe::SESSION_FIXATION) end
detected_sql_injection?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 18 def detected_sql_injection?(issue) patterns = [ 'sql injection', 'sqlinj', 'sqli', 'sql inj' ] cwe_found?(issue, patterns, SastBox::Cwe::SQL_INJECTION) end
detected_unrestricted_file_upload?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 154 def detected_unrestricted_file_upload?(issue) patterns = [ 'unrestricted upload', 'unrestricted file upload', ] cwe_found?(issue, patterns, SastBox::Cwe::UNRESTRICTED_UPLOAD_OF_FILE_WITH_DANGEROUS_TYPE) end
detected_xss?(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 28 def detected_xss?(issue) patterns = [ 'xss', 'cross-site scripting', 'cross site scripting', 'html injection' ] cwe_found?(issue, patterns, SastBox::Cwe::XSS) end
guess_cwe(issue)
click to toggle source
# File lib/sastbox-sdk/cwe_detector.rb, line 193 def guess_cwe(issue) if issue.key?(:cwe_id) cwe_start_heuristics(issue) if [SastBox::Cwe::UNDEF, -1, nil].include?(issue[:cwe_id]) else cwe_start_heuristics(issue) end end