Skip to content

Commit

Permalink
fix(CVE): upgrade spring & refactor to fix CVEs from GCP Marketplace (#…
Browse files Browse the repository at this point in the history
…74)

* fix(CVE): upgrade spring & refactor to fix CVEs from GCP Marketplace

* fix(CVE): upgrade musl version
  • Loading branch information
edgarulg authored Jul 7, 2023
1 parent a6ac1d4 commit 28d08e6
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN apk add --update --upgrade \
RUN apk update \
&& apk upgrade \
&& rm -rf /var/cache/apk/* \
&& apk add musl=1.2.3-r4 \
&& apk add musl=1.2.3-r5 \
&& apk add krb5-libs=1.20.1-r0

# Google cloud SDK with anthos removed for CVE and because we don't need it
Expand Down
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ subprojects {
annotationProcessor "org.projectlombok:lombok"
testAnnotationProcessor platform("io.spinnaker.kork:kork-bom:$korkVersion")
testAnnotationProcessor "org.projectlombok:lombok"

api(platform("org.springframework.boot:spring-boot-dependencies:2.7.11"))
api(platform("org.springframework.cloud:spring-cloud-dependencies:2021.0.3"))
}

publishing {
Expand Down Expand Up @@ -102,15 +105,15 @@ subprojects {
force group: 'org.apache.commons', name: 'commons-compress', version: '1.+' // Remove CVE-2019-12402, upgrade commons-compress dependency
force group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
force group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.41' // Remove CVE-2020-13934, CVE-2020-9484
force group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.5.10' // Avoid duplicate groovy versions 2.5.7 and 2.5.10
force group: 'org.codehaus.plexus', name: 'plexus-utils', version: '3.3.+' // Remove CVEs SONATYPE-2015-0173 and SONATYPE-2016-0398, upgrade plexus-utils dependency
force group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.1.+' // Remove CVE-2019-10219, upgrade hibernate-validator depende force group: 'org.testng', name: 'testng', version: '7.1.+' // Remove CVE SONATYPE-2019-0115, upgrade testng dependency
force group: 'org.javassist', name: 'javassist', version: '3.19.0-GA'
force group: 'org.jboss.logging', name: 'jboss-logging', version: '3.4.+' // Remove CVE-2017-2595, upgrade jboss-logging
force group: 'org.springframework.security', name: 'spring-security-core', version: '5.2.6.RELEASE' // Remove CVE-2020-5407
force group: 'org.springframework.security', name: 'spring-security-crypto', version: '5.2.4.RELEASE' // Remove CVE-2020-5408
force group: 'org.testng', name: 'testng', version: '7.1.+' // Remove CVE SONATYPE-2019-0115, upgrade testng dependency
force group: 'org.yaml', name: 'snakeyaml', version: '1.26' // Remove CVE-2017-18640
force group: 'org.yaml', name: 'snakeyaml', version: '2.0' // CVE-2022-1471
force group: 'org.apache.ivy', name: 'ivy', version: '2.5.1' // CVE-2022-37865
force group: 'org.spockframework', name:'spock-core', version:'2.0-groovy-3.0'

}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ artifactory_user=
artifactory_password=
clouddriverVersion=5.78.2
fiatVersion=1.27.1
korkVersion=7.158.0
korkVersion=7.169.1
front50Version=2.24.0
org.gradle.parallel=true
spinnakerGradleVersion=8.25.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.representer.Representer;
Expand Down Expand Up @@ -55,7 +56,8 @@ private static Yaml getYamlParser() {
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);

return new Yaml(new SafeConstructor(), new Representer(), options);
return new Yaml(
new SafeConstructor(new LoaderOptions()), new Representer(new DumperOptions()), options);
}

private static ObjectMapper getObjectMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.representer.Representer;
Expand Down Expand Up @@ -102,7 +103,8 @@ Yaml yamlParser() {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
return new Yaml(new SafeConstructor(), new Representer(), options);
return new Yaml(
new SafeConstructor(new LoaderOptions()), new Representer(new DumperOptions()), options);
}

private String normalizePath(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
import com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
public class PersistentStorageService {
@Autowired private LookupService lookupService;

@Autowired private DeploymentService deploymentService;
@Lazy @Autowired private DeploymentService deploymentService;

@Autowired private ValidateService validateService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class DeploymentEnvironmentValidator extends Validator<DeploymentEnvironment> {
@Autowired AccountService accountService;
@Lazy @Autowired AccountService accountService;

@Autowired KubernetesAccountValidator kubernetesAccountValidator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component;

@Component
public class GCSValidator extends Validator<GcsPersistentStore> {
@Autowired private AccountService accountService;
@Lazy @Autowired private AccountService accountService;

@Autowired private Registry registry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
import com.netflix.spinnaker.halyard.config.services.v1.ProviderService;
import com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
public class AwsAccountValidator extends Validator<AwsAccount> {

@Autowired ProviderService providerService;
@Lazy @Autowired ProviderService providerService;

@Override
public void validate(ConfigProblemSetBuilder p, AwsAccount awsAccount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
public class EcsAccountValidator extends Validator<EcsAccount> {
@Autowired ProviderService providerService;
@Lazy @Autowired ProviderService providerService;

@Autowired AccountService accountService;
@Lazy @Autowired AccountService accountService;

@Autowired ConfigService configService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

Expand All @@ -52,7 +53,7 @@ public boolean isUseRemoteDaemon() {

public static GlobalApplicationOptions getInstance() {
if (GlobalApplicationOptions.options == null) {
Yaml yamlParser = new Yaml(new SafeConstructor());
Yaml yamlParser = new Yaml(new SafeConstructor(new LoaderOptions()));
ObjectMapper objectMapper = new ObjectMapper();

objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;

Expand All @@ -44,9 +45,9 @@
public class GoogleProfileReader implements ProfileReader {
@Autowired String spinconfigBucket;

@Autowired Storage applicationDefaultGoogleStorage;
@Lazy @Autowired Storage applicationDefaultGoogleStorage;

@Autowired Storage unauthenticatedGoogleStorage;
@Lazy @Autowired Storage unauthenticatedGoogleStorage;

@Autowired ObjectMapper relaxedObjectMapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class VersionsSpec extends Specification {

def "orderBySemVer throws an exception for invalid versions"() {
when:
dev versions = ["1.0.0", badVersion]
def versions = ["1.0.0", badVersion]
Collections.sort(versions, Versions.orderBySemVer())

then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -47,7 +48,7 @@ public abstract class SpinnakerMonitoringDaemonService

@Autowired MetricRegistryProfileFactoryBuilder metricRegistryProfileFactoryBuilder;

@Autowired List<SpinnakerService> services;
@Lazy @Autowired List<SpinnakerService> services;

@Override
public SpinnakerArtifact getArtifact() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
@Component
@Data
public class GoogleConsulServerService extends ConsulServerService
implements GoogleDistributedService<ConsulApi> {
@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public String getDefaultInstanceType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
@Component
@Data
public class GoogleVaultServerService extends VaultServerService
implements GoogleDistributedService<VaultServerService.Vault> {
@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public String getDefaultInstanceType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Data
Expand All @@ -35,7 +36,7 @@ public class KubernetesV2MonitoringDaemonService extends SpinnakerMonitoringDaem
implements KubernetesV2Service<SpinnakerMonitoringDaemonService.SpinnakerMonitoringDaemon> {
final DeployPriority deployPriority = new DeployPriority(0);

@Delegate @Autowired KubernetesV2ServiceDelegate serviceDelegate;
@Lazy @Delegate @Autowired KubernetesV2ServiceDelegate serviceDelegate;

@Override
public boolean runsOnJvm() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

Expand Down Expand Up @@ -178,12 +179,12 @@ public ResourceSpec createResourceSpec(
}

public String prettify(String input) {
Yaml yaml = new Yaml(new SafeConstructor());
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
return yaml.dump(yaml.load(input));
}

public Map<String, Object> parseManifest(String input) {
Yaml yaml = new Yaml(new SafeConstructor());
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
return mapper.convertValue(yaml.load(input), new TypeReference<Map<String, Object>>() {});
}

Expand Down

1 comment on commit 28d08e6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Security Scan Results ⚠️
Found 12 Critical Vulnerabilities
Found 33 High Vulnerabilities

See scan details for more information.

Please sign in to comment.