Esempio n. 1
0
 def __init__(self, options: dict) -> None:
     self.scan_rules = options.get('sgrep_rules')
     self.show_progress = options.get('show_progress')
     exts = options.get('sgrep_extensions')
     if exts:
         self.exts = [ext.lower() for ext in exts]
     else:
         self.exts = []
     self.findings = {
         'matches': {},
         'errors': [],
     }
     self.standards = standards.get_standards()
Esempio n. 2
0
def test_semgrep():
    stds = standards.get_standards()
    result = scanner({}).scan()
    match = result['semantic_grep']['matches']['boto-client-ip']
    assert match
    assert match['files'][0]['match_position']
    assert match['files'][0]['match_lines']
    assert match['files'][0]['file_path']
    assert match['metadata']
    assert match['metadata']['description']
    assert match['metadata']['severity']
    assert match['metadata']['cwe'] == stds['cwe']['cwe-1050']
    assert match['metadata']['owasp-web'] == stds['owasp-web']['a8']
Esempio n. 3
0
 def __init__(self, paths, json, check_controls, config=False) -> None:
     conf = get_config(paths, config)
     self.check_controls = check_controls
     self.options = {
         'match_rules': settings.PATTERN_RULES_DIR,
         'sgrep_rules': settings.SGREP_RULES_DIR,
         'sgrep_extensions': conf['nodejs_extensions'],
         'match_extensions': conf['template_extensions'],
         'ignore_filenames': conf['ignore_filenames'],
         'ignore_extensions': conf['ignore_extensions'],
         'ignore_paths': conf['ignore_paths'],
         'ignore_rules': conf['ignore_rules'],
         'severity_filter': conf['severity_filter'],
         'show_progress': not json,
     }
     self.paths = paths
     self.result = {
         'templates': {},
         'nodejs': {},
         'errors': [],
     }
     self.standards = standards.get_standards()
# -*- coding: utf_8 -*-
"""IPA Binary Analysis Rules."""
from libsast.standards import get_standards

STDS = get_standards()
IPA_RULES = [
    {
        'description':
        'Binary makes use of insecure API(s)',
        'detailed_desc': ('The binary may contain'
                          ' the following insecure API(s) {}.'),
        'type':
        'Regex',
        'pattern':
        (rb'\b_alloca\b|\b_gets\b|\b_memcpy\b|\b_printf\b|\b_scanf\b|'
         rb'\b_sprintf\b|\b_sscanf\b|\b_strcat\b|'
         rb'\bStrCat\b|\b_strcpy\b|\bStrCpy\b|\b_strlen\b|\bStrLen\b|'
         rb'\b_strncat\b|\bStrNCat\b|\b_strncpy\b|'
         rb'\bStrNCpy\b|\b_strtok\b|\b_swprintf\b|\b_vsnprintf\b|'
         rb'\b_vsprintf\b|\b_vswprintf\b|\b_wcscat\b|\b_wcscpy\b|'
         rb'\b_wcslen\b|\b_wcsncat\b|\b_wcsncpy\b|\b_wcstok\b|\b_wmemcpy\b|'
         rb'\b_fopen\b|\b_chmod\b|\b_chown\b|\b_stat\b|\b_mktemp\b'),
        'severity':
        'high',
        'input_case':
        'exact',
        'cvss':
        6,
        'cwe':
        STDS['cwe']['cwe-676'],
        'owasp-mobile':