This repository was archived by the owner on Nov 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Feat/include #59
Open
wurstbrot
wants to merge
4
commits into
main
Choose a base branch
from
feat/include
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/include #59
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: v1 | ||
| kind: application | ||
| settings: | ||
| desired level: Level 2 | ||
| application: "kube" | ||
| team: "ops" | ||
|
|
||
| activities: | ||
| Source Control Protection: | ||
| components: | ||
| - url: "https://test1.com" | ||
| date: 2023-01-01 | ||
| - date: 2022-05-01 | ||
| url: "https://test1.com" | ||
| - date: 2021-05-01 | ||
| url: "https://test1.com" | ||
| - date: 2023-12-19 | ||
| url: "https://test1.com" |
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,38 @@ | ||
| apiVersion: v1 | ||
| kind: team | ||
|
|
||
| settings: | ||
| team: "ops" | ||
|
|
||
| activities: | ||
| Security requirements: | ||
| components: | ||
| - url: "https://test1.com" | ||
| date: 2023-01-01 | ||
| - date: 2022-05-01 | ||
| url: "https://test1.com" | ||
| - date: 2021-05-01 | ||
| url: "https://test1.com" | ||
| - date: 2023-12-19 | ||
| url: "https://test1.com" | ||
|
|
||
| Data privacy requirements: | ||
| components: | ||
| - date: 2022-05-01 | ||
| - date: 2021-05-01 | ||
| - date: 2023-12-19 | ||
|
|
||
| Security champion: | ||
| components: | ||
| - firstname: "Max" | ||
| lastname: "Mustermann" | ||
| date: "2020-11-01" | ||
|
|
||
| Security Training: | ||
| components: | ||
| - date: "2020-11-01" | ||
| people: 2 | ||
| hours: 5 | ||
| - date: "2023-11-01" | ||
| people: 2 | ||
| hours: 5 |
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
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
71 changes: 71 additions & 0 deletions
71
src/main/java/org/owasp/dsomm/metricca/analyzer/deserialization/YamlScannerIncludes.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,71 @@ | ||
| package org.owasp.dsomm.metricca.analyzer.deserialization; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.node.ArrayNode; | ||
| import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
| public class YamlScannerIncludes { | ||
| private final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | ||
| private final String yamlBasePath; | ||
| private final JsonNode applicationJsonNode; | ||
|
|
||
| public YamlScannerIncludes(JsonNode applicationJsonNode, String basePath) { | ||
| this.applicationJsonNode = applicationJsonNode; | ||
| this.yamlBasePath = basePath; | ||
| } | ||
|
|
||
| public JsonNode getNode() throws IOException { | ||
| processIncludes(applicationJsonNode); | ||
| return applicationJsonNode; | ||
| } | ||
|
|
||
| private void processIncludes(JsonNode node) throws IOException { | ||
| if (node.has("includes")) { | ||
| ArrayNode includesArray = (ArrayNode) node.get("includes"); | ||
| for (JsonNode includeNode : includesArray) { | ||
| if (includeNode.isTextual()) { | ||
| String includePath = includeNode.asText(); | ||
| File includeFile = new File(yamlBasePath + File.separator + includePath); | ||
| JsonNode includeContent = mapper.readTree(includeFile); | ||
| if (includeContent.has("includes")) { | ||
| processIncludes(includeContent); | ||
wurstbrot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| mergeJsonNodes(node, includeContent); | ||
| } | ||
| } | ||
| ((ObjectNode) node).remove("includes"); | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| private void mergeJsonNodes(JsonNode destinationNode, JsonNode sourceNode) { | ||
| if (destinationNode instanceof ObjectNode destObjectNode && sourceNode instanceof ObjectNode srcObjectNode) { | ||
|
|
||
| // Merge fields from source node to destination node | ||
| srcObjectNode.fieldNames().forEachRemaining(fieldName -> { | ||
| JsonNode srcFieldValue = srcObjectNode.get(fieldName); | ||
| JsonNode destFieldValue = destObjectNode.get(fieldName); | ||
|
|
||
| if (destFieldValue != null && destFieldValue.isObject() && srcFieldValue.isObject()) { | ||
| // Recursive deep merge for nested objects | ||
| mergeJsonNodes(destFieldValue, srcFieldValue); | ||
| } else { | ||
| // If the field exists in the destination node but not in the source node, or if the field is null in the destination | ||
| // and exists in the source node, or if the included YAML is overriding the including YAML, override the value in the destination | ||
| if (destFieldValue == null || (!destObjectNode.has(fieldName) && srcObjectNode.has(fieldName))) { | ||
| destObjectNode.set(fieldName, srcFieldValue); | ||
| } | ||
| } | ||
| }); | ||
| } else { | ||
| throw new IllegalArgumentException("Both nodes must be ObjectNodes"); | ||
| } | ||
| } | ||
|
|
||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| logging.level.root=INFO | ||
| metricCA.resource.path=/app/resources | ||
| spring.config.import: ${metricCA.resource.path}/application-prod.properties | ||
| spring.config.import= ${metricCA.resource.path}/application-prod.properties | ||
| logging.level.org.eclipse.jgit=DEBUG |
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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| metricCA.resource.path=/app/src/main/resources/ | ||
| spring.config.import: ${metricCA.resource.path}/application-prod.properties | ||
| spring.config.import= ${metricCA.resource.path}/application-prod.properties |
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.
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.