-
Notifications
You must be signed in to change notification settings - Fork 16
feat: source_uuid to multiscan #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: source_uuid to multiscan #147
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #147 +/- ##
==========================================
- Coverage 95.77% 95.57% -0.20%
==========================================
Files 5 5
Lines 1208 1244 +36
==========================================
+ Hits 1157 1189 +32
- Misses 51 55 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
89889f1
to
90b4d91
Compare
02eb61e
to
ea1cd34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I am curious about how one does obtain this source_uuid.
839ff83
to
0f89473
Compare
@agateau-gg I added new changes, we are finally using a new endpoint for issue creation, since we predict that the issue creation flow might change (new parameters specific only for issue creations etc). Could you please re-review the MR? |
…the found secrets
0f89473
to
8b80880
Compare
def scan_and_create_incidents( | ||
self, | ||
documents: List[Dict[str, str]], | ||
source_uuid: UUID, | ||
extra_headers: Optional[Dict[str, str]] = None, | ||
params: Optional[Dict[str, Any]] = None, | ||
) -> Union[Detail, MultiScanResult]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need that params
argument? I think it would be better to have properly typed optional arguments than a pass-through like this.
Also, can you mark optional arguments as keyword-only by adding a *
before extra_headers
so that we can safely reorder them if need be?
class DocumentsForIncidentCreationSchema(BaseSchema): | ||
documents = fields.List(fields.Nested(DocumentSchema), required=True) | ||
source_uuid = fields.UUID(required=True) | ||
|
||
@post_dump | ||
def transform_filename_to_document_identifier( | ||
self, data: Dict[str, Any], **kwargs: Any | ||
) -> Dict[str, Any]: | ||
"""Transform filename field to document_identifier in the documents list""" | ||
if "documents" in data: | ||
for document in data["documents"]: | ||
if "filename" in document: | ||
document["document_identifier"] = document.pop("filename") | ||
return data | ||
|
||
|
||
class DocumentsForIncidentCreation(Base): | ||
""" | ||
DocumentsForIncidentCreation is a request object for communicating a list of documents | ||
along with a source UUID to the API for incident creation | ||
|
||
Attributes: | ||
documents (List[Document]): list of documents to scan | ||
source_uuid (UUID): UUID identifying the source | ||
""" | ||
|
||
SCHEMA = DocumentsForIncidentCreationSchema() | ||
|
||
def __init__(self, documents: List[Document], source_uuid: UUID, **kwargs: Any): | ||
super().__init__() | ||
self.documents = documents | ||
self.source_uuid = source_uuid | ||
|
||
def __repr__(self) -> str: | ||
return f"documents:{len(self.documents)}, source_uuid:{self.source_uuid}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can avoid adding these classes: scan_and_create_incidents()
can do something like this:
payload = {
"source_uuid": source_uuid,
"documents": [{
"document_identifier": x["filename],
"document": x["document"],
} for x in documents]
}
When source_uuid parameter is provided for the multiscan endpoint, the incidents will be
created for the found secrets