(data, extractor, definitions, matcher=None)
| 16 | |
| 17 | |
| 18 | def scan(data, extractor, definitions, matcher=None): |
| 19 | matcher = matcher or _simple_match |
| 20 | detected = [] |
| 21 | for component in definitions: |
| 22 | extractors = definitions[component].get( |
| 23 | "extractors", None).get( |
| 24 | extractor, None) |
| 25 | if (not is_defined(extractors)): |
| 26 | continue |
| 27 | for i in extractors: |
| 28 | match = matcher(i, data) |
| 29 | if (match): |
| 30 | detected.append({"version": match, |
| 31 | "component": component, |
| 32 | "detection": extractor}) |
| 33 | return detected |
| 34 | |
| 35 | |
| 36 | def _simple_match(regex, data): |
no test coverage detected