2020-05-26 15:37:24 +02:00
|
|
|
#!/usr/bin/env python
|
2024-01-17 13:13:14 +01:00
|
|
|
|
|
|
|
from __future__ import annotations
|
2020-05-26 15:37:24 +02:00
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2024-02-01 14:40:12 +01:00
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
from .abstractgenerator import AbstractMISPObjectGenerator
|
|
|
|
|
2020-05-26 15:37:24 +02:00
|
|
|
logger = logging.getLogger('pymisp')
|
|
|
|
|
|
|
|
|
|
|
|
class GitVulnFinderObject(AbstractMISPObjectGenerator):
|
|
|
|
|
2024-02-01 14:40:12 +01:00
|
|
|
def __init__(self, parameters: dict[str, Any], strict: bool = True, **kwargs) -> None: # type: ignore[no-untyped-def]
|
2021-10-28 22:29:27 +02:00
|
|
|
super().__init__('git-vuln-finder', strict=strict, **kwargs)
|
2020-05-26 15:37:24 +02:00
|
|
|
self._parameters = parameters
|
|
|
|
self.generate_attributes()
|
|
|
|
|
2024-02-01 14:40:12 +01:00
|
|
|
def generate_attributes(self) -> None:
|
2020-05-26 15:37:24 +02:00
|
|
|
authored_date = self._sanitize_timestamp(self._parameters.pop('authored_date', None))
|
|
|
|
self._parameters['authored_date'] = authored_date
|
|
|
|
committed_date = self._sanitize_timestamp(self._parameters.pop('committed_date', None))
|
|
|
|
self._parameters['committed_date'] = committed_date
|
|
|
|
if 'stats' in self._parameters:
|
|
|
|
stats = self._parameters.pop('stats')
|
|
|
|
self._parameters['stats.insertions'] = stats.pop('insertions')
|
|
|
|
self._parameters['stats.deletions'] = stats.pop('deletions')
|
|
|
|
self._parameters['stats.lines'] = stats.pop('lines')
|
|
|
|
self._parameters['stats.files'] = stats.pop('files')
|
2021-10-28 22:29:27 +02:00
|
|
|
super().generate_attributes()
|