Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-approve for bulk upload #2600

Merged
merged 33 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1b0b763
Delete processed files
nulls Sep 14, 2023
7aee4fa
diktatFix & detektAll
nulls Sep 14, 2023
377c7e4
renamed run configuration for gradle tasks
nulls Sep 14, 2023
b29fe30
added a workaround
nulls Sep 14, 2023
13de609
removed CosvStorage
nulls Sep 14, 2023
9c44f48
added a link from CosvFile to VulnerabilityMetadata
nulls Sep 14, 2023
42c5fdd
Merge remote-tracking branch 'origin/master' into feature/link-metada…
nulls Sep 14, 2023
78d2650
saving a file before a metadata
nulls Sep 14, 2023
f7e0250
WIP
nulls Sep 15, 2023
90b1be9
refactored CosvRepository
nulls Sep 15, 2023
b0bc367
fixed CosvProcessor
nulls Sep 15, 2023
9008cd2
diktatFix
nulls Sep 15, 2023
b7c5941
diktatFix & detektAll + refactored to when
nulls Sep 15, 2023
e42be98
removed unused method
nulls Sep 15, 2023
520a2ef
refactored liquibase scripts to resolve ordering issue
nulls Sep 15, 2023
b2b40f1
diktatFix
nulls Sep 15, 2023
e0af470
Merge remote-tracking branch 'origin/master' into feature/link-metada…
nulls Sep 15, 2023
8fe634a
updated test data
nulls Sep 15, 2023
f930df5
fixed liquibase insert
nulls Sep 15, 2023
e96c3fd
Merge remote-tracking branch 'origin/master' into feature/link-metada…
nulls Sep 15, 2023
9bc2da4
Merge remote-tracking branch 'origin/master' into feature/link-metada…
nulls Sep 18, 2023
603ee12
added removing all keys at once
nulls Sep 18, 2023
d87b6ce
diktatFix
nulls Sep 18, 2023
ace055d
deleted unexpected files
nulls Sep 18, 2023
c6423e0
Auto-approve for bulk upload
nulls Sep 18, 2023
fce0710
diktatFix
nulls Sep 18, 2023
67ca9dc
Merge remote-tracking branch 'origin/master' into feature/auto-approv…
nulls Sep 18, 2023
0def4ad
fixed manual vulnerabilities
nulls Sep 19, 2023
613c768
diktatFix
nulls Sep 19, 2023
71ae2aa
latest_cosv_id is required now
nulls Sep 19, 2023
3e1d689
reverted unused changes
nulls Sep 19, 2023
f46df0c
added a mock repository to fix tests
nulls Sep 19, 2023
a469348
fixed searching by identifier
nulls Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions db/test-data/cosv-file-insert.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="cosv-file-insert" author="nulls" context="dev">
<loadData tableName="cosv_file" separator=";" file="db/test-data/sqlRequests/cosv-file.csv">
<column header="id" name="id" type="NUMERIC" />
<column header="identifier" name="identifier" type="varchar(250)" />
<column header="modified" name="modified" type="DATE" />
<column header="prev_cosv_file_id" name="prev_cosv_file_id" type="NUMERIC"/>
</loadData>
</changeSet>

</databaseChangeLog>
1 change: 1 addition & 0 deletions db/test-data/db.changelog-insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<include file="file-insert.xml" relativeToChangelogFile="true"/>
<include file="lnk-execution-file-insert.xml" relativeToChangelogFile="true"/>
<include file="tests-source-version-insert.xml" relativeToChangelogFile="true"/>
<include file="cosv-file-insert.xml" relativeToChangelogFile="true"/>
<include file="vulnerability-metadata-insert.xml" relativeToChangelogFile="true"/>
<include file="vulnerability-metadata-project-insert.xml" relativeToChangelogFile="true"/>
<include file="lnk-vulnerability-metadata-user-insert.xml" relativeToChangelogFile="true"/>
Expand Down
6 changes: 6 additions & 0 deletions db/test-data/sqlRequests/cosv-file.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id;identifier;modified;prev_cosv_file_id
1;CVE-2022-25296;2021-01-01 00:00:00.000;
2;CVE-2022-25365;2021-01-01 00:00:00.000;
3;CVE-2023-22475;2021-01-01 00:00:00.000;
4;CVE-2022-44697;2021-01-01 00:00:00.000;
5;CVE-2022-22978;2021-01-01 00:00:00.000;
12 changes: 6 additions & 6 deletions db/test-data/sqlRequests/vulnerability-metadata.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id;identifier;severity_num;submitted;modified;user_id;details;summary;language;organization_id;status
1;"CVE-2022-22978";9.8;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"In Spring Security versions 5.5.6 and 5.6.3 and older unsupported versions, RegexRequestMatcher can easily be misconfigured to be bypassed on some servlet containers. Applications using RegexRequestMatcher with `.` in the regular expression are possibly vulnerable to an authorization bypass";Incorrect Authorization;JAVA;1;APPROVED
2;"CVE-2022-44697";7.8;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED
3;"CVE-2023-22475";6.1;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED
4;"CVE-2022-25365";7.8;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED
5;"CVE-2022-25296";7.3;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED
id;identifier;severity_num;submitted;modified;user_id;details;summary;language;organization_id;status;latest_cosv_file_id
1;"CVE-2022-22978";9.8;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"In Spring Security versions 5.5.6 and 5.6.3 and older unsupported versions, RegexRequestMatcher can easily be misconfigured to be bypassed on some servlet containers. Applications using RegexRequestMatcher with `.` in the regular expression are possibly vulnerable to an authorization bypass";Incorrect Authorization;JAVA;1;APPROVED;5
2;"CVE-2022-44697";7.8;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED;4
3;"CVE-2023-22475";6.1;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED;3
4;"CVE-2022-25365";7.8;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED;2
5;"CVE-2022-25296";7.3;"2021-01-01 00:00:00";"2021-01-01 00:00:00";1;"New description";Short description;JAVA;;APPROVED;1
3 changes: 2 additions & 1 deletion db/test-data/vulnerability-metadata-insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="vulnerability-metadata-insert" author="nulls" context="dev">
<loadData tableName="vulnerability_metadata" encoding="UTF-8" separator=";" quotchar="&quot;" file="db/test-data/sqlRequests/vulnerability-metadata.csv">
<loadData tableName="vulnerability_metadata" separator=";" file="db/test-data/sqlRequests/vulnerability-metadata.csv">
<column header="id" name="id" type="bigint"/>
<column header="identifier" name="identifier" type="varchar(100)"/>
<column header="severity_num" name="severity_num" type="DECIMAL(2,1)"/>
Expand All @@ -18,6 +18,7 @@
<column header="language" name="language" type="varchar(64)"/>
<column header="organization_id" name="organization_id" type="bigint"/>
<column header="status" name="status" type="varchar(64)"/>
<column header="latest_cosv_file_id" name="latest_cosv_file_id" type="bigint"/>
</loadData>
</changeSet>

Expand Down
1 change: 1 addition & 0 deletions db/v-2/tables/db.changelog-tables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<include file="lnk-vulnerability-metadata-user.xml" relativeToChangelogFile="true"/>
<include file="vulnerability-metadata-project.xml" relativeToChangelogFile="true"/>
<include file="cosv-file.xml" relativeToChangelogFile="true"/>
<include file="link-between-cosv-file-and-vulnerability-metadata.xml" relativeToChangelogFile="true"/>

<changeSet id="02-tables" author="frolov">
<tagDatabase tag="v2.0-tables"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="link-cosv-file-and-vulnerability-metadata" author="nulls">
<addColumn tableName="cosv_file">
<column name="prev_cosv_file_id" type="bigint">
<constraints nullable="true"/>
</column>
</addColumn>
<addForeignKeyConstraint baseTableName="cosv_file" baseColumnNames="prev_cosv_file_id"
constraintName="fk_cosv_file_prev_cosv_file"
referencedTableName="cosv_file"
referencedColumnNames="id"
onDelete="CASCADE"/>

<addColumn tableName="vulnerability_metadata">
<column name="latest_cosv_file_id" type="bigint">
<constraints nullable="true"/>
</column>
</addColumn>
<addForeignKeyConstraint baseTableName="vulnerability_metadata" baseColumnNames="latest_cosv_file_id"
constraintName="fk_vulnerability_metadata_latest_cosv_file"
referencedTableName="cosv_file"
referencedColumnNames="id"
onDelete="CASCADE"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ class VulnerabilityController(
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
fun delete(
@RequestParam identifier: String,
): Mono<StringResponse> = vulnerabilityService.delete(identifier)
): Mono<StringResponse> = blockingToMono { vulnerabilityService.delete(identifier) }
.flatMapMany { vulnerabilityService.deleteAllVersions(identifier) }
.thenJust(
ResponseEntity.ok("Vulnerability $identifier was successfully deleted")
)
Expand Down
Loading
Loading