-
Notifications
You must be signed in to change notification settings - Fork 46
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
Record alerts as part of the pipeline #197
Conversation
@@ -1,99 +1,24 @@ | |||
-- name: CreatePrompt :one |
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.
Deleted the unused queries
@@ -28,3 +32,18 @@ async def get_messages() -> List[Conversation]: | |||
|
|||
conversations = await match_conversations(partial_conversations) | |||
return conversations | |||
|
|||
|
|||
@dashboard_router.get("/dashboard/alerts") |
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.
Second endpoint. I still need to implement some filtering for @peppescg
@@ -11,300 +11,87 @@ | |||
from codegate.db import models | |||
|
|||
|
|||
CREATE_ALERT = """-- name: create_alert \\:one | |||
INSERT INTO alerts ( |
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.
This file got shrink down when I deleted most of the queries.
|
||
def add_code_snippet(self, snippet: CodeSnippet): | ||
self.code_snippets.append(snippet) | ||
|
||
def get_snippets_by_language(self, language: str) -> List[CodeSnippet]: | ||
return [s for s in self.code_snippets if s.language.lower() == language.lower()] | ||
|
||
def add_alert( |
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.
This is what adds alerts to the context
|
||
# Add the remaining content if any | ||
if after: | ||
chunks.append(self._create_chunk(chunk, after)) | ||
complete_comment += after | ||
|
||
# Add an alert to the context |
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 want to add an alert for all code snippets or only those that contain some bad packages (which I know is in progress, asking for later)
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.
My initial thought was basically to save an alert for everything that we do and have different levels of alerts or notifications: INFO
and CRITICAL
. We can add more if we want:
INFO
would be for routinely stuff like "hey we detected this code snippet as part of our pipeline".CRITICAL
would be for malicious packages or detected secrets
@@ -69,6 +69,9 @@ async def process( | |||
|
|||
# If matches are found, add the matched content to context | |||
if len(searched_objects) > 0: | |||
# Add an alert to the context | |||
context.add_alert(self.name, trigger_string=last_user_message_str) | |||
|
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.
This might be worth rebasing atop Pankaj's PR to be able to add alerts on different kids of packages (mal/archived/...)
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 this is fine and most importantly allows you and Giuseppe to move forward. We might want to tune what do we alert on just before the release.
The alerts are recorded in the `context` of the pipeline execution. At the end of the pipeline the recorded alerts will go into the DB. - The alerts are recorded for both input and output pipelines - The alerts are recorded in the pipeline steps. If a step took an action an alert gets recorded - There are 2 levels of alerts for the moment: `INFO` and `CRITICAL` - Most of the steps record `INFO` alerts with the exception of secrets.
5bb9665
to
446c226
Compare
Record alerts as part of the pipeline
The alerts are recorded in the
context
of the pipeline execution. At the end of the pipeline the recorded alerts will go into the DB.INFO
andCRITICAL
INFO
alerts with the exception of secrets.