Skip to content

Commit

Permalink
Kill criticals (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexroan authored Apr 11, 2024
1 parent 97b75d6 commit b9a388e
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 81 deletions.
2 changes: 0 additions & 2 deletions aderyn_core/src/detect/detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ pub enum IssueSeverity {
Low,
Medium,
High,
Critical,
}

impl Display for IssueSeverity {
Expand All @@ -195,7 +194,6 @@ impl Display for IssueSeverity {
IssueSeverity::Low => "Low",
IssueSeverity::Medium => "Medium",
IssueSeverity::High => "High",
IssueSeverity::Critical => "Critical",
};
write!(f, "{}", issue_description).unwrap();
Ok(())
Expand Down
3 changes: 0 additions & 3 deletions aderyn_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ where

for (issue, severity) in issues.into_iter().flatten() {
match severity {
IssueSeverity::Critical => {
report.criticals.push(issue);
}
IssueSeverity::High => {
report.highs.push(issue);
}
Expand Down
7 changes: 2 additions & 5 deletions aderyn_core/src/report/json_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ use crate::context::workspace_context::WorkspaceContext;
use serde::Serialize;

use super::{
printer::ReportPrinter, reporter::Report, CriticalIssues, FilesDetails, FilesSummary,
HighIssues, IssueCount, LowIssues, MediumIssues, NcIssues,
printer::ReportPrinter, reporter::Report, FilesDetails, FilesSummary, HighIssues, IssueCount,
LowIssues, MediumIssues, NcIssues,
};

#[derive(Serialize)]
pub struct JsonContent {
files_summary: FilesSummary,
files_details: FilesDetails,
issue_count: IssueCount,
critical_issues: CriticalIssues,
high_issues: HighIssues,
medium_issues: MediumIssues,
low_issues: LowIssues,
Expand All @@ -32,7 +31,6 @@ pub struct JsonPrinter;
"files_summary": {...},
"files_details": {...},
"issue_summary": {...},
"critical_issues": {...},
"high_issues": {...},
...
}
Expand All @@ -56,7 +54,6 @@ impl ReportPrinter<()> for JsonPrinter {
files_summary: context.files_summary(),
files_details: context.files_details(),
issue_count: report.issue_count(),
critical_issues: report.critical_issues(),
high_issues: report.high_issues(),
medium_issues: report.medium_issues(),
low_issues: report.low_issues(),
Expand Down
7 changes: 0 additions & 7 deletions aderyn_core/src/report/markdown_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ impl ReportPrinter<()> for MarkdownReportPrinter {
}

let all_issues = vec![
(report.critical_issues().issues, "# Critical Issues\n", "C"),
(report.high_issues().issues, "# High Issues\n", "H"),
(report.medium_issues().issues, "# Medium Issues\n", "M"),
(report.low_issues().issues, "# Low Issues\n", "L"),
Expand Down Expand Up @@ -147,7 +146,6 @@ impl MarkdownReportPrinter {
// Start the markdown table
writeln!(writer, "| Category | No. of Issues |")?;
writeln!(writer, "| --- | --- |")?;
writeln!(writer, "| Critical | {} |", issue_count.critical)?;
writeln!(writer, "| High | {} |", issue_count.high)?;
writeln!(writer, "| Medium | {} |", issue_count.medium)?;
writeln!(writer, "| Low | {} |", issue_count.low)?;
Expand Down Expand Up @@ -197,11 +195,6 @@ impl MarkdownReportPrinter {
writeln!(writer, " - [Issue Summary](#issue-summary)")?;

let issues = [
(
&report.criticals,
"- [Critical Issues](#critical-issues)",
"C",
),
(&report.highs, "- [High Issues](#high-issues)", "H"),
(&report.mediums, "- [Medium Issues](#medium-issues)", "M"),
(&report.lows, "- [Low Issues](#low-issues)", "L"),
Expand Down
6 changes: 0 additions & 6 deletions aderyn_core/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct FilesDetail {

#[derive(Serialize)]
pub struct IssueCount {
critical: usize,
high: usize,
medium: usize,
low: usize,
Expand All @@ -61,11 +60,6 @@ pub struct IssueBody {
instances: Vec<IssueInstance>,
}

#[derive(Serialize)]
pub struct CriticalIssues {
issues: Vec<IssueBody>,
}

#[derive(Serialize)]
pub struct HighIssues {
issues: Vec<IssueBody>,
Expand Down
11 changes: 1 addition & 10 deletions aderyn_core/src/report/reporter.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use super::{
extract_issue_bodies, CriticalIssues, HighIssues, Issue, IssueCount, LowIssues, MediumIssues,
NcIssues,
extract_issue_bodies, HighIssues, Issue, IssueCount, LowIssues, MediumIssues, NcIssues,
};

#[derive(Default, PartialEq)]
pub struct Report {
pub criticals: Vec<Issue>,
pub highs: Vec<Issue>,
pub mediums: Vec<Issue>,
pub lows: Vec<Issue>,
Expand All @@ -15,20 +13,13 @@ pub struct Report {
impl Report {
pub fn issue_count(&self) -> IssueCount {
IssueCount {
critical: self.criticals.len(),
high: self.highs.len(),
medium: self.mediums.len(),
low: self.lows.len(),
nc: self.ncs.len(),
}
}

pub fn critical_issues(&self) -> CriticalIssues {
CriticalIssues {
issues: extract_issue_bodies(&self.criticals),
}
}

pub fn high_issues(&self) -> HighIssues {
HighIssues {
issues: extract_issue_bodies(&self.highs),
Expand Down
1 change: 0 additions & 1 deletion judgeops/current/report-config.judge.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati

| Category | No. of Issues |
| --- | --- |
| Critical | 0 |
| High | 0 |
| Medium | 0 |
| Low | 1 |
Expand Down
1 change: 0 additions & 1 deletion judgeops/current/report.judge.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati

| Category | No. of Issues |
| --- | --- |
| Critical | 0 |
| High | 2 |
| Medium | 4 |
| Low | 7 |
Expand Down
30 changes: 15 additions & 15 deletions judgeops/samples/sample_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@
"metrics": {
"centralization-risk": {
"detector_name": "centralization-risk",
"true_positives": 5,
"true_positives": 4,
"false_positives": 1,
"trigger_count": 6,
"experience": 7,
"trigger_count": 5,
"experience": 6,
"current_severity": "Medium"
},
"delegate-call-in-loop": {
"detector_name": "delegate-call-in-loop",
"true_positives": 5,
"true_positives": 4,
"false_positives": 2,
"trigger_count": 7,
"experience": 7,
"trigger_count": 6,
"experience": 6,
"current_severity": "High"
},
"push-zero-opcode": {
"detector_name": "push-zero-opcode",
"true_positives": 5,
"true_positives": 4,
"false_positives": 0,
"trigger_count": 5,
"experience": 7,
"trigger_count": 4,
"experience": 6,
"current_severity": "Low"
},
"solmate-safe-transfer-lib": {
"detector_name": "solmate-safe-transfer-lib",
"true_positives": 5,
"true_positives": 4,
"false_positives": 1,
"trigger_count": 7,
"experience": 7,
"trigger_count": 6,
"experience": 6,
"current_severity": "Medium"
},
"useless-public-function": {
"detector_name": "useless-public-function",
"true_positives": 5,
"true_positives": 4,
"false_positives": 0,
"trigger_count": 6,
"experience": 9,
"trigger_count": 5,
"experience": 8,
"current_severity": "NC"
}
},
Expand Down
2 changes: 0 additions & 2 deletions judgeops/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub enum IssueSeverity {
Low,
Medium,
High,
Critical,
}

impl Display for IssueSeverity {
Expand All @@ -34,7 +33,6 @@ impl Display for IssueSeverity {
IssueSeverity::Low => "Low",
IssueSeverity::Medium => "Medium",
IssueSeverity::High => "High",
IssueSeverity::Critical => "Critical",
};
write!(f, "{}", issue_description).unwrap();
Ok(())
Expand Down
4 changes: 1 addition & 3 deletions judgeops/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ pub(crate) fn register_unseen_detectors(
println!("Registering {} {}", detector_name, severity);
// let assigned_severity: IssueSeverity = serde_json::from_str(&severity).unwrap();

let assigned_severity = if severity == &IssueSeverity::Critical.to_string() {
IssueSeverity::Critical
} else if severity == &IssueSeverity::High.to_string() {
let assigned_severity = if severity == &IssueSeverity::High.to_string() {
IssueSeverity::High
} else if severity == &IssueSeverity::Medium.to_string() {
IssueSeverity::Medium
Expand Down
29 changes: 14 additions & 15 deletions judgeops/src/watchtower/lightchaser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ impl InfersMetrics for Metrics {
}

match self.current_severity {
IssueSeverity::Critical => lc_accuracy == IssueSeverity::COUNT as u64,
IssueSeverity::High => lc_accuracy >= IssueSeverity::COUNT as u64 - 1,
IssueSeverity::Medium => lc_accuracy >= IssueSeverity::COUNT as u64 - 2,
IssueSeverity::Low => lc_accuracy >= IssueSeverity::COUNT as u64 - 3,
Expand Down Expand Up @@ -408,7 +407,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 4);
assert!(current_metrics.lc_accuracy() == 3);
assert!(current_metrics.is_acceptable());

watchtower.take_feedback(Feedback {
Expand All @@ -422,7 +421,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 3);
assert!(current_metrics.lc_accuracy() == 2);
assert!(current_metrics.is_acceptable());

watchtower.take_feedback(Feedback {
Expand All @@ -436,7 +435,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 2);
assert!(current_metrics.lc_accuracy() == 1);
assert!(!current_metrics.is_acceptable());
}

Expand Down Expand Up @@ -503,7 +502,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 4);
assert!(current_metrics.lc_accuracy() == 3);

watchtower.take_feedback(Feedback {
positive_feedbacks: vec![],
Expand All @@ -516,7 +515,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 3);
assert!(current_metrics.lc_accuracy() == 2);

watchtower.take_feedback(Feedback {
positive_feedbacks: vec![],
Expand All @@ -529,7 +528,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 2);
assert!(current_metrics.lc_accuracy() == 1);

watchtower.take_feedback(Feedback {
positive_feedbacks: vec![IssueDetectorNamePool::CentralizationRisk.to_string()],
Expand All @@ -542,7 +541,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 3);
assert!(current_metrics.lc_accuracy() == 2);

watchtower.take_feedback(Feedback {
positive_feedbacks: vec![IssueDetectorNamePool::CentralizationRisk.to_string()],
Expand All @@ -555,7 +554,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 4);
assert!(current_metrics.lc_accuracy() == 3);
}

#[test]
Expand All @@ -578,7 +577,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 5);
assert!(current_metrics.lc_accuracy() == 4);

watchtower.take_feedback(Feedback {
positive_feedbacks: vec![IssueDetectorNamePool::CentralizationRisk.to_string()],
Expand All @@ -591,7 +590,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 5);
assert!(current_metrics.lc_accuracy() == 4);
}

#[test]
Expand All @@ -614,7 +613,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 5);
assert!(current_metrics.lc_accuracy() == 4);

watchtower.take_feedback(Feedback {
positive_feedbacks: vec![],
Expand All @@ -627,7 +626,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 4);
assert!(current_metrics.lc_accuracy() == 3);

watchtower.take_feedback(Feedback {
positive_feedbacks: vec![IssueDetectorNamePool::CentralizationRisk.to_string()],
Expand All @@ -640,7 +639,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 4);
assert!(current_metrics.lc_accuracy() == 3);
}

#[test]
Expand All @@ -663,7 +662,7 @@ mod lightchaser_tests {

let current_metrics =
watchtower.metrics(IssueDetectorNamePool::CentralizationRisk.to_string());
assert!(current_metrics.lc_accuracy() == 5);
assert!(current_metrics.lc_accuracy() == 4);

for _ in 1..=5 {
watchtower.take_feedback(Feedback {
Expand Down
4 changes: 0 additions & 4 deletions report-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"critical_issues": {
"issues": []
},
"detectors_used": [
"push-zero-opcode",
"useless-public-function"
Expand Down Expand Up @@ -46,7 +43,6 @@
"issues": []
},
"issue_count": {
"critical": 0,
"high": 0,
"low": 1,
"medium": 0,
Expand Down
Loading

0 comments on commit b9a388e

Please sign in to comment.