Skip to content

Email Notification Feature for casr-dojo#258

Open
PavlNekrasov wants to merge 1 commit intoispras:masterfrom
PavlNekrasov:add_send_email
Open

Email Notification Feature for casr-dojo#258
PavlNekrasov wants to merge 1 commit intoispras:masterfrom
PavlNekrasov:add_send_email

Conversation

@PavlNekrasov
Copy link
Contributor

Hi,
I needed email notifications when crashes are uploaded to DefectDojo for my workflow, so I've implemented this functionality. If you find it useful, please consider merging this addition.

Reporter: Pavel Nekrasov (p.nekrasov@fobos-nt.ru)

@codecov
Copy link

codecov bot commented Apr 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 155 lines in your changes missing coverage. Please review.

Project coverage is 65.06%. Comparing base (3dfa879) to head (36c25eb).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
casr/src/bin/casr-dojo.rs 0.00% 155 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #258      +/-   ##
==========================================
- Coverage   66.35%   65.06%   -1.30%     
==========================================
  Files          34       34              
  Lines        8246     8310      +64     
==========================================
- Hits         5472     5407      -65     
- Misses       2774     2903     +129     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@SweetVishnya SweetVishnya left a comment

Choose a reason for hiding this comment

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

Please, run cargo fmt and cargo clippy on your code

@SweetVishnya
Copy link
Collaborator

Doesn't DefectDojo support setting up email notifications from its web ui?

I am wondering whether it is a good point to send emails directly from Casr...


[dependencies]
lettre = "0.11.15"
secrecy = "0.8"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, make these dependencies available only when casr is built with dojo feature (similar to tokio crate).


Triage crashes found by libFuzzer based fuzzer
(C/C++/go-fuzz/Atheris/Jazzer/Jazzer.js/jsfuzz/luzer) or LibAFL based fuzzer
(C/C++/go-fuzz/Atheris/Jazzer/Jazzer.js/jsfuzz) or LibAFL based fuzzer
Copy link
Collaborator

Choose a reason for hiding this comment

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

redundant change

[test]
test_type = "CASR DAST Report"
```
Also `casr-dojo` can send email notifications about newly uploaded findings. To enable this feature, add a `[mail]` section to your TOML configuration file:
Copy link
Collaborator

Choose a reason for hiding this comment

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

add newline here

}
}

struct FindingInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add docs for structures, fields, and functions

}

Ok(())
Ok(FindingInfo {
Copy link
Collaborator

@SweetVishnya SweetVishnya Apr 6, 2025

Choose a reason for hiding this comment

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

You may just return JSON stored to finding variable. Thus, you won't need declaring an additional structure. Id can be stored in finding["id"].

d
}

fn parse_env_var(s: &str) -> Option<&str> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can hardcore exactly one supported environment variable CASR_MAIL_PASSWORD?


impl MailConfig {
pub fn new(toml: toml::Table, defectdojo_url: String) -> Result<Option<Self>> {
if !toml.contains_key("mail") || !toml["mail"].is_table() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

non-table 'mail' should be an error

return Ok(None);
}

let mail_settings = toml["mail"].as_table().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

You may just write as_table()? to handle non-table case

) {
Ok(Some(config)) => config,
Ok(None) => {
warn!("Mail configuration not found in TOML, skipping notifications");
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be no warning here

@SweetVishnya SweetVishnya added the enhancement New feature or request label Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants