8000
Skip to content

Email Notification Feature for casr-dojo - #258

Open
PavlNekrasov wants to merge 1 commit into
ispras:masterfrom
PavlNekrasov:add_send_email
Open

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

Conversation

@PavlNekrasov
Copy link
Copy Markdown
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
codecov Bot commented Apr 6, 2025
Copy link
Copy Markdown

Codecov Report

❌ 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 23 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 Harness.
📢 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.

@SweetVishnya SweetVishnya left a comment
Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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...

Comment thread casr/Cargo.toml

[dependencies]
lettre = "0.11.15"
secrecy = "0.8"
Copy link
Copy Markdown
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).

Comment thread docs/usage.md

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

redundant change

Comment thread docs/usage.md
[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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add newline here

Comment thread casr/src/bin/casr-dojo.rs
}
}

struct FindingInfo {
Copy link
Copy Markdown
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

Comment thread casr/src/bin/casr-dojo.rs
}

Ok(())
Ok(FindingInfo {
@SweetVishnya SweetVishnya Apr 6, 2025
Copy link
Copy Markdown
Collaborator

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"].

Comment thread casr/src/bin/casr-dojo.rs
d
}

fn parse_env_var(s: &str) -> Option<&str> {
Copy link
Copy Markdown
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?

Comment thread casr/src/bin/casr-dojo.rs

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

< 6880 input type="hidden" name="authenticity_token" value="kS8kOonhreMNmnJKTASsZDkrAXisblEZGo3w__5J__jYjBJukQGSJ9YHrI-D9IpPrDCpApP6Mu1idgKlsgxHlQ" autocomplete="off" />

non-table 'mail' should be an error

Comment thread casr/src/bin/casr-dojo.rs
return Ok(None);
}

let mail_settings = toml["mail"].as_table().unwrap();
Copy link
Copy Markdown
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

Comment thread casr/src/bin/casr-dojo.rs
) {
Ok(Some(config)) => config,
Ok(None) => {
warn!("Mail configuration not found in TOML, skipping notifications");
Copy link
Copy Markdown
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

0