forked from trustification/trustify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow calculation of CVSS3 score using SQL functions, like a madman.
Provide enough escape-hatches around filterin/sorting to do my evil deeds. Do some evil deeds in SQL to allow sorting/filtering by synthetic `average_score` on advisories. Do even more evil, by writing entirely too many SQL functions. Lay in appropriate DOWN migration for cvss3 scoring functions.
- Loading branch information
Bob McWhirter
committed
Jun 11, 2024
1 parent
968fb08
commit 26a977b
Showing
10 changed files
with
515 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.get_connection() | ||
.execute_unprepared(include_str!("m0000315_create_cvss3_scoring_function.sql")) | ||
.await | ||
.map(|_| ()) | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_score"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_exploitability"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_impact"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_av_score"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_ac_score"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_pr_scoped_score"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_ui_score"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_scope_changed"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_c_score"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_i_score"#) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared(r#"drop function cvss3_a_score"#) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.