Skip to content

Risk dashboard UI#46

Merged
marcorosa merged 16 commits intodevelopfrom
risk-dashboard-ui
Jun 25, 2025
Merged

Risk dashboard UI#46
marcorosa merged 16 commits intodevelopfrom
risk-dashboard-ui

Conversation

@cabch
Copy link
Copy Markdown
Contributor

@cabch cabch commented May 13, 2025

added risk dashboard

  • button at the bottom + ui in new tab
  • changed favicon
  • changed font

Caroline BANCHEREAU added 2 commits May 13, 2025 11:03
- button at the bottom + ui in new tab
- changed favicon
- changed font
deleted unused html comments
@cabch cabch requested a review from a team as a code owner May 13, 2025 09:09
@cabch cabch requested a review from marcorosa May 13, 2025 09:09
@marcorosa marcorosa changed the base branch from main to develop May 13, 2025 09:11
Copy link
Copy Markdown
Member

@marcorosa marcorosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few minor comments. Plus, please fix the pep8 style errors from the bot

Comment thread backend-agent/main.py Outdated
Comment thread backend-agent/main.py Outdated
@marcorosa
Copy link
Copy Markdown
Member

@cabch I tested the branch and I have some comments:

  • the names of the 2 files are hardcoded, but they are hardcoded only at read-time. This means the users must be aware they HAVE TO use the names STARS_RESULTS.csv and attacks.csv. So, maybe it's a good idea to rename them at upload time (if this is possible)
  • Both the 2 files are needed to show the dashboard, so we can consider to force users to upload them together (with 2 upload buttons and a confirmation that is unlocked only if both the 2 files are selected)
  • the distinction modelType│version│specialization│other is not needed. We should keep the whole model name together (for instance, llama-3.1-70b-instruct should stay all together, no need to divide version, number of hyper-parameters and fine tuning indication) because that's how it appears on AI Core
  • attacks.csv is used for the exposure score, but maybe it's better to keep this formula in the code instead of in a separate csv of 1 line that has to be uploaded (moreover, all the attacks should be taken into consideration in the formula.. we can discuss on this in a separate channel)
  • In my (local) test, the providers were not shown (undefined is shown in their place) but there is no trace of error in the logs (only 200 responses)
    📄 Reading CSV from: dashboard/STARS_RESULTS.csv
    127.0.0.1 - - [14/May/2025 10:16:22] "GET /api/vendors HTTP/1.1" 200 -
    127.0.0.1 - - [14/May/2025 10:16:22] "GET /api/heatmap HTTP/1.1" 200 -
    127.0.0.1 - - [14/May/2025 10:16:22] "GET /api/attacks HTTP/1.1" 200 -
    

aligned attacks results
TODO: textattack
@cabch cabch changed the title Risk dashboard UI 🚧 WIP : Risk dashboard UI Jun 17, 2025
Copy link
Copy Markdown
Member

@marcorosa marcorosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @cabch I have finished the review :D
You will find some comments in the files, plus a few paragraphs here below to clarify a few points that require more than 1 line of text to be expressed.

db model for Model

I think there is some confusion on the way you call the models once stored in the db. Indeed, "Attack Model" would be good if that wasn't already used in the individual attacks with a different meaning. If we want to align to the naming we currently have, then the model under attack is the "target model", whereas the "attack model" is an llm used in some attacks (like pyrit) to mutate the attack prompts (so, it's used as an "evil attacker" and not as a target).

save_to_db call

I think there is space for optimizing the way we call the save_to_db function. Indeed, the call is added to each attack implementation (i.e., each file in libs, plus the attack suite). This way, every time we add a new attack, we have to remember to also save the results to the db. I think we can keep it this way for now, but keeping it in mind for our possible future restructuring of the project. As an alternative, the call to save results to db could be done in the AttackSpecification, as part of the start method (but it would require to process the result there) or somewhere else.

gptfuzz

It's not very clear to me the way results are returned. On my side, I must run it once again to refresh my memory, but still what is currently returned as part of the AttackResult needs a revision.

AttackResult

It is not clear if we need to standardize the returns, because you haven't been consistent across all the attacks. If so, we can also consider switching AttackResult.details json/dictionary to a dataclass to be more rigorous.

Style comments

The style of imports needs to be reviewed. From PEP8 definitions:

Imports should be grouped in the following order:
1. Standard library imports.
2. Related third party imports.
3. Local application/library specific imports.

In addition, each block should be sorted alphabetically.

Comment thread backend-agent/attack.py Outdated
Comment thread backend-agent/libs/artprompt.py Outdated
Comment thread backend-agent/libs/artprompt.py Outdated
Comment thread backend-agent/libs/codeattack.py Outdated
Comment thread backend-agent/libs/codeattack.py Outdated
Comment thread backend-agent/app/db/utils.py Outdated
Comment thread backend-agent/app/db/utils.py
Comment thread backend-agent/app/db/utils.py
Comment thread backend-agent/app/db/utils.py Outdated
db.session.commit()
print("Results successfully saved to the database.")
return inserted_records
except Exception as e:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also for the exception blocks, 2 comments you have already seen :D

  • use logger instead of print
  • try to make the exception a little less generic, if possible

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done ✅ + same comments as for adding an utility function for exception handling ? avoiding to avoid cluttering the code every time error handling is needed... need to check again

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding multiple exception in a row

@marcorosa marcorosa mentioned this pull request Jun 20, 2025
7 tasks
Copy link
Copy Markdown
Member

@marcorosa marcorosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 minor comments

Comment thread backend-agent/main.py Outdated
Comment thread backend-agent/main.py Outdated
@marcorosa
Copy link
Copy Markdown
Member

@cabch ignore the frontend-linter action (that's broken and it has been fixed in the other pull request #44 currently open), but please fix the errors raised by the python linter

@marcorosa marcorosa merged commit 9b9f1dd into develop Jun 25, 2025
5 of 6 checks passed
@marcorosa
Copy link
Copy Markdown
Member

I merge the current PR to start working on its dockerization, but there are some runtime errors when running the attacks (both via UI and docker)

@marcorosa
Copy link
Copy Markdown
Member

marcorosa commented Jun 25, 2025

Working on the runtime exceptions in the fix/app-db branch.
tested and working
via cli.py

  • promptmap
  • codeattack
  • artpromopt
  • pyrit
  • gptfuzz

via agent ui

  • promptmap
  • codeattack
  • artpromopt
  • pyrit
  • gptfuzz

vulnerability_type = attack_results.vulnerability_type.lower()
details = attack_results.details # JSON column
target_name = details.get('target_model')
target_name = details.get('target_model', '').lower()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it works if we don't have the target model ? we deleted the tolower() and moved it below in case we cannot find the target name it doesn't crash

@cabch cabch changed the title 🚧 WIP : Risk dashboard UI Risk dashboard UI Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants