-
Notifications
You must be signed in to change notification settings - Fork 50
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
Poc secrets #9539
Draft
benoitgravitee
wants to merge
7
commits into
master
Choose a base branch
from
poc-secrets
base: master
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.
Draft
Poc secrets #9539
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
59161b5
feat: rtsec step1
benoitgravitee ea326c1
feat: prep for poc demo
benoitgravitee 9b72a81
fix: demo fixes
benoitgravitee 3eb90da
fix: renewals
benoitgravitee ab5a5ca
feat: secret kind and field check
benoitgravitee a81eb3c
fix: move field ACL in common
benoitgravitee 17d4791
fix: extract async resolution
benoitgravitee 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 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
131 changes: 131 additions & 0 deletions
131
...l/src/main/java/io/gravitee/definition/model/services/secrets/ApiV4DefinitionBrowser.java
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,131 @@ | ||
package io.gravitee.definition.model.services.secrets; | ||
|
||
import static io.gravitee.node.api.secrets.runtime.discovery.PayloadLocation.PLUGIN_KIND; | ||
|
||
import io.gravitee.definition.model.v4.Api; | ||
import io.gravitee.definition.model.v4.endpointgroup.service.EndpointGroupServices; | ||
import io.gravitee.definition.model.v4.endpointgroup.service.EndpointServices; | ||
import io.gravitee.definition.model.v4.flow.Flow; | ||
import io.gravitee.definition.model.v4.plan.PlanSecurity; | ||
import io.gravitee.definition.model.v4.service.Service; | ||
import io.gravitee.node.api.secrets.runtime.discovery.Definition; | ||
import io.gravitee.node.api.secrets.runtime.discovery.DefinitionBrowser; | ||
import io.gravitee.node.api.secrets.runtime.discovery.DefinitionPayloadNotifier; | ||
import io.gravitee.node.api.secrets.runtime.discovery.PayloadLocation; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* @author Benoit BORDIGONI (benoit.bordigoni at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public class ApiV4DefinitionBrowser implements DefinitionBrowser<Api> { | ||
|
||
@Override | ||
public boolean canHandle(Object definition) { | ||
return definition != null && Objects.equals(definition.getClass(), Api.class); | ||
} | ||
|
||
@Override | ||
public Definition getDefinitionLocation(Api definition, Map<String, String> metadata) { | ||
return new Definition("api-v4", metadata.get("api_cross_id"), Optional.ofNullable(metadata.get("deployment_number"))); | ||
} | ||
|
||
@Override | ||
public void findPayloads(Api definition, DefinitionPayloadNotifier notifier) { | ||
// listeners | ||
definition | ||
.getListeners() | ||
.stream() | ||
.flatMap(l -> l.getEntrypoints().stream()) | ||
.forEach(entrypoint -> { | ||
String payload = entrypoint.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, entrypoint.getType()), entrypoint::setConfiguration); | ||
}); | ||
|
||
// resources | ||
definition | ||
.getResources() | ||
.forEach(resource -> { | ||
String payload = resource.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, resource.getType()), resource::setConfiguration); | ||
}); | ||
|
||
// flows api and plan | ||
List<Flow> flows = definition | ||
.getPlans() | ||
.stream() | ||
.flatMap(p -> p.getFlows().stream()) | ||
.collect(Collectors.toCollection(ArrayList::new)); | ||
flows.addAll(definition.getFlows()); | ||
Stream | ||
.concat( | ||
Stream.concat( | ||
flows.stream().flatMap(flow -> flow.getRequest().stream()), | ||
flows.stream().flatMap(flow -> flow.getResponse().stream()) | ||
), | ||
Stream.concat( | ||
flows.stream().flatMap(flow -> flow.getPublish().stream()), | ||
flows.stream().flatMap(flow -> flow.getSubscribe().stream()) | ||
) | ||
) | ||
.forEach(step -> { | ||
var payload = step.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, step.getPolicy()), step::setConfiguration); | ||
}); | ||
|
||
definition | ||
.getPlans() | ||
.forEach(plan -> { | ||
PlanSecurity security = plan.getSecurity(); | ||
String payload = security.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, security.getType()), security::setConfiguration); | ||
}); | ||
|
||
// endpoint groups | ||
definition | ||
.getEndpointGroups() | ||
.stream() | ||
.flatMap(endpointGroup -> { | ||
EndpointGroupServices services = endpointGroup.getServices(); | ||
Stream | ||
.of(services.getDiscovery(), services.getHealthCheck()) | ||
.filter(Service::isEnabled) | ||
.forEach(service -> { | ||
String payload = service.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, service.getType()), service::setConfiguration); | ||
}); | ||
String payload = endpointGroup.getSharedConfiguration(); | ||
notifier.onPayload( | ||
payload, | ||
new PayloadLocation(PLUGIN_KIND, endpointGroup.getType()), | ||
endpointGroup::setSharedConfiguration | ||
); | ||
return endpointGroup.getEndpoints().stream(); | ||
}) | ||
.forEach(endpoint -> { | ||
EndpointServices services = endpoint.getServices(); | ||
Stream | ||
.of(services.getHealthCheck()) | ||
.filter(Service::isEnabled) | ||
.forEach(service -> { | ||
String payload = service.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, service.getType()), service::setConfiguration); | ||
}); | ||
String payload = endpoint.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, endpoint.getType()), endpoint::setConfiguration); | ||
payload = endpoint.getSharedConfigurationOverride(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, endpoint.getType()), endpoint::setSharedConfigurationOverride); | ||
}); | ||
|
||
// services | ||
Service dynamicProperty = definition.getServices().getDynamicProperty(); | ||
String payload = dynamicProperty.getConfiguration(); | ||
notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, dynamicProperty.getType()), dynamicProperty::setConfiguration); | ||
} | ||
} |
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
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
20 changes: 20 additions & 0 deletions
20
...er/src/main/java/io/gravitee/gateway/standalone/secrets/DefinitionBrowserBeanFactory.java
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,20 @@ | ||
package io.gravitee.gateway.standalone.secrets; | ||
|
||
import io.gravitee.definition.model.services.secrets.ApiV4DefinitionBrowser; | ||
import io.gravitee.definition.model.v4.Api; | ||
import io.gravitee.node.api.secrets.runtime.discovery.DefinitionBrowser; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author Benoit BORDIGONI (benoit.bordigoni at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
@Configuration | ||
public class DefinitionBrowserBeanFactory { | ||
|
||
@Bean | ||
DefinitionBrowser<Api> apiV4() { | ||
return new ApiV4DefinitionBrowser(); | ||
} | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vulnerability ID: CVE-2024-38820
Check Name: The fix for CVE-2022-22968 made disallowedFieldspatterns in DataBinder ...
Severity: MEDIUM
Fixed Version: 6.1.14, 6.0.25, 5.3.41, 6.2.0-RC2
Reachable Path(s) Found: No
Description: The fix for CVE-2022-22968 made disallowedFields patterns in DataBinder case insensitive. However, String.toLowerCase() has some Locale dependent exceptions that could potentially result in fields not protected as expected.
[This comment was created by Aqua Pipeline]
Read more at https://avd.aquasec.com/nvd/cve-2024-38820