-
Notifications
You must be signed in to change notification settings - Fork 211
[backend] feat(stix): artifact management (#3511) #4950
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
379490f
[backend] feat(stix): prepare artifact management (#3511)
gabriel-peze cf4e0bf
[backend] feat(stix): poc some process (#3511)
gabriel-peze 14a0189
[backend] feat(stix): review process (#3511)
gabriel-peze 149c4eb
[backend] feat(stix): WIP (#3511)
gabriel-peze 66f6b11
[backend] feat(stix): try to download file from octi (#3511)
gabriel-peze cf28d64
[backend] feat(stix): wip (#3511)
gabriel-peze 450bade
[backend] feat(stix): wip (#3511)
gabriel-peze cbd92fb
[backend] feat(stix): wip (#3511)
gabriel-peze aa0d0c6
[backend] feat(stix): add artifacts management on stix bundle (#3511)
gabriel-peze 9542db9
[backend] feat(stix): remove host starting (#3511)
gabriel-peze 444eb5e
[backend] feat(stix): fix prereview issues (#3511)
gabriel-peze fc4a6bf
[backend] feat(stix): fix tests (#3511)
gabriel-peze f34de84
[backend] feat(stix): wip (#3511)
gabriel-peze 2c100db
[backend] feat(stix): increase test coverage (#3511)
gabriel-peze 3d5e652
[backend] feat(stix): update migration version (#3511)
gabriel-peze 4d6dbfa
[backend] feat(stix): fix send to OCTI informations (#3511)
gabriel-peze cf361c9
[backend] feat(stix): fix pr feedbacks (#3511)
gabriel-peze 1d3f136
[backend] feat(stix): fix pr feedbacks (#3511)
gabriel-peze f5f608d
[backend] feat(stix): fix pr feedbacks (#3511)
gabriel-peze 06eb2a7
[backend] feat(stix): fix pr feedbacks (#3511)
gabriel-peze 65ae16a
[frontend] feat(stix): add tooltip (#3511)
gabriel-peze d8e7b73
[frontend] feat(stix): fix lint (#3511)
gabriel-peze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
.../src/main/java/io/openaev/migration/V4_75__Add_artifacts_column_to_security_coverage.java
This file contains hidden or 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,86 @@ | ||
| package io.openaev.migration; | ||
|
|
||
| import java.sql.Statement; | ||
| import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
| import org.flywaydb.core.api.migration.Context; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class V4_75__Add_artifacts_column_to_security_coverage extends BaseJavaMigration { | ||
| @Override | ||
| public void migrate(Context context) throws Exception { | ||
| try (Statement stmt = context.getConnection().createStatement()) { | ||
| stmt.execute( | ||
| "ALTER TABLE security_coverages ADD COLUMN IF NOT EXISTS security_coverage_artifacts_refs JSONB;"); | ||
|
|
||
| stmt.execute( | ||
| """ | ||
| UPDATE security_coverages | ||
| SET security_coverage_vulnerabilities_refs = ( | ||
| CASE | ||
| WHEN security_coverage_vulnerabilities_refs IS NULL\s | ||
| OR jsonb_array_length(security_coverage_vulnerabilities_refs) = 0\s | ||
| THEN security_coverage_vulnerabilities_refs | ||
|
|
||
| ELSE ( | ||
| SELECT jsonb_agg( | ||
| jsonb_set( | ||
| elem - 'external_ref', | ||
| '{external_refs}', | ||
| jsonb_build_array(elem->>'external_ref') | ||
| ) | ||
| ) | ||
| FROM jsonb_array_elements(security_coverage_vulnerabilities_refs) AS elem | ||
| ) | ||
| END | ||
| ); | ||
| """); | ||
|
|
||
| stmt.execute( | ||
| """ | ||
| UPDATE security_coverages | ||
| SET security_coverage_attack_pattern_refs = ( | ||
| CASE | ||
| WHEN security_coverage_attack_pattern_refs IS NULL\s | ||
| OR jsonb_array_length(security_coverage_attack_pattern_refs) = 0\s | ||
| THEN security_coverage_attack_pattern_refs | ||
|
|
||
| ELSE ( | ||
| SELECT jsonb_agg( | ||
| jsonb_set( | ||
| elem - 'external_ref', | ||
| '{external_refs}', | ||
| jsonb_build_array(elem->>'external_ref') | ||
| ) | ||
| ) | ||
| FROM jsonb_array_elements(security_coverage_attack_pattern_refs) AS elem | ||
| ) | ||
| END | ||
| ); | ||
| """); | ||
|
|
||
| stmt.execute( | ||
| """ | ||
| UPDATE security_coverages | ||
| SET security_coverage_indicators_refs = ( | ||
| CASE | ||
| WHEN security_coverage_indicators_refs IS NULL\s | ||
| OR jsonb_array_length(security_coverage_indicators_refs) = 0\s | ||
| THEN security_coverage_indicators_refs | ||
|
|
||
| ELSE ( | ||
| SELECT jsonb_agg( | ||
| jsonb_set( | ||
| elem - 'external_ref', | ||
| '{external_refs}', | ||
| jsonb_build_array(elem->>'external_ref') | ||
| ) | ||
| ) | ||
| FROM jsonb_array_elements(security_coverage_indicators_refs) AS elem | ||
| ) | ||
| END | ||
| ); | ||
| """); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
openaev-api/src/main/java/io/openaev/opencti/client/response/ResponseFile.java
This file contains hidden or 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,14 @@ | ||
| package io.openaev.opencti.client.response; | ||
|
|
||
| import java.io.InputStream; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| public class ResponseFile { | ||
|
|
||
| private long size; | ||
|
|
||
| private InputStream inputStream; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.