Skip to content

Commit

Permalink
Merge pull request #750 from catenax-ng/chore/TRACEFOSS-XXX-fix-mediu…
Browse files Browse the repository at this point in the history
…m-findings

chore: TRACEFOSS-XXX update SecurityConfig to not use deprecated methods
  • Loading branch information
ds-lcapellino authored Nov 9, 2023
2 parents fa9a376 + 50cf209 commit 7a48403
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/helm-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
version: v3.9.3

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.4.0
uses: helm/chart-testing-action@v2.6.1

- name: Run chart-testing (list-changed)
id: list-changed
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Frontend adapt to backend api changes for activeAlerts and activeInvestigations
- Reconfigured all docker images user settings
- Adapted memory / cpu requests and limits in default values helm file
- Migrate to not deprecated methods in HTTP security

### Removed

Expand Down
13 changes: 3 additions & 10 deletions charts/traceability-foss/charts/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,16 @@ serviceAccount:

podAnnotations: { }

podSecurityContext:
runAsUser: 10001
seccompProfile:
type: RuntimeDefault
podSecurityContext: { }
# fsGroup: 2000

# Following Catena-X Helm Best Practices @url: https://catenax-ng.github.io/docs/kubernetes-basics/helm
# @url: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 3000
capabilities:
drop:
- ALL
readOnlyRootFilesystem: false
runAsUser: 101
# runAsGroup: 3000

service:
type: ClusterIP
Expand Down
14 changes: 4 additions & 10 deletions charts/traceability-foss/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,16 @@ frontend:

podAnnotations: {}

podSecurityContext:
runAsUser: 10001
seccompProfile:
type: RuntimeDefault
podSecurityContext: {}
# fsGroup: 2000

# Following Catena-X Helm Best Practices @url: https://catenax-ng.github.io/docs/kubernetes-basics/helm
# @url: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 3000
capabilities:
drop:
- ALL
readOnlyRootFilesystem: false
runAsUser: 101
# runAsGroup: 3000

service:
type: ClusterIP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface AssetRepository {

List<AssetBase> getAssetsById(List<String> assetIds);

AssetBase getAssetByChildId(String assetId, String childId);
AssetBase getAssetByChildId(String childId);

PageResult<AssetBase> getAssets(Pageable pageable, SearchCriteria searchCriteria);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public List<AssetBase> getAssetsById(List<String> assetIds) {

@Override
public AssetBase getAssetByChildId(String assetId, String childId) {
return getAssetRepository().getAssetByChildId(assetId, childId);
return getAssetRepository().getAssetByChildId(childId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public List<AssetBase> getAssetsById(List<String> assetIds) {
}

@Override
public AssetBase getAssetByChildId(String assetId, String childId) {
public AssetBase getAssetByChildId(String childId) {
return jpaAssetAsBuiltRepository.findById(childId)
.map(AssetAsBuiltEntity::toDomain)
.orElseThrow(() -> new AssetNotFoundException("Child Asset Not Found"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<AssetBase> getAssetsById(List<String> assetIds) {
}

@Override
public AssetBase getAssetByChildId(String assetId, String childId) {
public AssetBase getAssetByChildId(String childId) {
return jpaAssetAsPlannedRepository.findById(childId).map(AssetAsPlannedEntity::toDomain)
.orElseThrow(() -> new AssetNotFoundException("Child Asset Not Found"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
Expand Down Expand Up @@ -67,12 +69,12 @@ public class SecurityConfig {
@Bean
SecurityFilterChain securityFilterChain(final HttpSecurity httpSecurity) throws Exception {

httpSecurity.httpBasic().disable();
httpSecurity.formLogin().disable();
httpSecurity.logout().disable();
httpSecurity.anonymous().disable();
httpSecurity.csrf().disable();
httpSecurity.cors();
httpSecurity.httpBasic(AbstractHttpConfigurer::disable);
httpSecurity.formLogin(AbstractHttpConfigurer::disable);
httpSecurity.logout(AbstractHttpConfigurer::disable);
httpSecurity.anonymous(AbstractHttpConfigurer::disable);
httpSecurity.csrf(AbstractHttpConfigurer::disable);
httpSecurity.cors(Customizer.withDefaults());


httpSecurity.authorizeHttpRequests(auth -> auth
Expand All @@ -81,10 +83,10 @@ SecurityFilterChain securityFilterChain(final HttpSecurity httpSecurity) throws
.anyRequest()
.authenticated());

httpSecurity.oauth2ResourceServer(oauth2ResourceServer -> oauth2ResourceServer.jwt()
.jwtAuthenticationConverter(
new JwtAuthenticationTokenConverter(resourceClient)))
.oauth2Client();
httpSecurity.oauth2ResourceServer(oauth2ResourceServer -> oauth2ResourceServer.jwt((jwt) -> jwt.jwtAuthenticationConverter(
new JwtAuthenticationTokenConverter(resourceClient)))
)
.oauth2Client(Customizer.withDefaults());

return httpSecurity.build();
}
Expand Down

0 comments on commit 7a48403

Please sign in to comment.