blob: e5c8a27debfb4cf6543ef0ae26aad962d46f9ed2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation;
import com.yahoo.config.application.api.ValidationId;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.vespa.model.VespaModel;
import java.util.ArrayList;
import java.util.List;
import static com.yahoo.collections.CollectionUtil.mkString;
import static com.yahoo.vespa.model.application.validation.first.AccessControlOnFirstDeploymentValidator.needsAccessControlValidation;
import static com.yahoo.vespa.model.container.http.AccessControl.hasHandlerThatNeedsProtection;
/**
* @author gjoranv
*/
public class AwsAccessControlValidator extends Validator {
@Override
public void validate(VespaModel model, DeployState deployState) {
if (! needsAccessControlValidation(model, deployState)) return;
if(! deployState.zone().getCloud().requireAccessControl()) return;
List<String> offendingClusters = new ArrayList<>();
for (var cluster : model.getContainerClusters().values()) {
var http = cluster.getHttp();
if (http == null
|| ! http.getAccessControl().isPresent()
|| ! http.getAccessControl().get().writeEnabled
|| ! http.getAccessControl().get().readEnabled)
if (hasHandlerThatNeedsProtection(cluster) || ! cluster.getAllServlets().isEmpty())
offendingClusters.add(cluster.getName());
}
if (! offendingClusters.isEmpty())
deployState.validationOverrides()
.invalid(ValidationId.accessControl,
"Access-control must be enabled for read/write operations to container clusters in AWS production zones: " +
mkString(offendingClusters, "[", ", ", "]"), deployState.now());
}
}
|