This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to enable WAF logging (#145)
- Loading branch information
1 parent
6b74a72
commit 81009e6
Showing
19 changed files
with
578 additions
and
11 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
|
||
group=com.nike | ||
artifactId=cerberus-lifecycle-cli | ||
version=4.12.2 | ||
version=4.13.0 |
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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/nike/cerberus/client/aws/KinesisFirehoseAwsClientFactory.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,41 @@ | ||
/* | ||
* Copyright (c) 2020 Nike, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nike.cerberus.client.aws; | ||
|
||
import com.amazonaws.regions.Regions; | ||
import com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehoseClient; | ||
import com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehoseClientBuilder; | ||
import com.nike.cerberus.service.AwsClientFactory; | ||
|
||
public class KinesisFirehoseAwsClientFactory extends AwsClientFactory<AmazonKinesisFirehoseClient> { | ||
|
||
@Override | ||
public AmazonKinesisFirehoseClient getClient(Regions region) { | ||
if (!clients.containsKey(region)) { | ||
clients.put(region, createClient(region)); | ||
} | ||
return clients.get(region); | ||
} | ||
|
||
private AmazonKinesisFirehoseClient createClient(Regions region) { | ||
return (AmazonKinesisFirehoseClient) AmazonKinesisFirehoseClientBuilder.standard() | ||
.withRegion(region) | ||
.withCredentials(getAWSCredentialsProviderChain()) | ||
.build(); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/nike/cerberus/client/aws/WafAwsClientFactory.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,41 @@ | ||
/* | ||
* Copyright (c) 2020 Nike, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nike.cerberus.client.aws; | ||
|
||
import com.amazonaws.regions.Regions; | ||
import com.amazonaws.services.waf.AWSWAFRegionalClient; | ||
import com.amazonaws.services.waf.AWSWAFRegionalClientBuilder; | ||
import com.nike.cerberus.service.AwsClientFactory; | ||
|
||
public class WafAwsClientFactory extends AwsClientFactory<AWSWAFRegionalClient> { | ||
|
||
@Override | ||
public AWSWAFRegionalClient getClient(Regions region) { | ||
if (!clients.containsKey(region)) { | ||
clients.put(region, createClient(region)); | ||
} | ||
return clients.get(region); | ||
} | ||
|
||
private AWSWAFRegionalClient createClient(Regions region) { | ||
return (AWSWAFRegionalClient) AWSWAFRegionalClientBuilder.standard() | ||
.withRegion(region) | ||
.withCredentials(getAWSCredentialsProviderChain()) | ||
.build(); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/com/nike/cerberus/command/core/CreateWafLoggingCommand.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,62 @@ | ||
/* | ||
* Copyright (c) 2020 Nike, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nike.cerberus.command.core; | ||
|
||
import com.beust.jcommander.Parameter; | ||
import com.beust.jcommander.Parameters; | ||
import com.beust.jcommander.ParametersDelegate; | ||
import com.nike.cerberus.command.Command; | ||
import com.nike.cerberus.domain.cloudformation.CloudFormationParametersDelegate; | ||
import com.nike.cerberus.operation.Operation; | ||
import com.nike.cerberus.operation.core.CreateWafLoggingOperation; | ||
|
||
import static com.nike.cerberus.command.core.CreateWafCommand.COMMAND_NAME; | ||
|
||
/** | ||
* Command to create the WAF logging for Cerberus. | ||
*/ | ||
@Parameters(commandNames = COMMAND_NAME, | ||
commandDescription = "Create the Web Application Firewall (WAF) logging.") | ||
public class CreateWafLoggingCommand implements Command { | ||
|
||
public static final String COMMAND_NAME = "create-waf-logging"; | ||
|
||
@ParametersDelegate | ||
private CloudFormationParametersDelegate cloudFormationParametersDelegate = new CloudFormationParametersDelegate(); | ||
|
||
@Parameter(names = {"--skip-stack-creation", "-s"}, description = "Skips WAF logging stack creation.") | ||
private boolean skipStackCreation; | ||
|
||
public boolean isSkipStackCreation() { | ||
return skipStackCreation; | ||
} | ||
|
||
public CloudFormationParametersDelegate getCloudFormationParametersDelegate() { | ||
return cloudFormationParametersDelegate; | ||
} | ||
|
||
@Override | ||
public String getCommandName() { | ||
return COMMAND_NAME; | ||
} | ||
|
||
@Override | ||
public Class<? extends Operation<?>> getOperationClass() { | ||
return CreateWafLoggingOperation.class; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/nike/cerberus/domain/cloudformation/WafLoggingOutputs.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,42 @@ | ||
/* | ||
* Copyright (c) 2020 Nike, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nike.cerberus.domain.cloudformation; | ||
|
||
/** | ||
* Represents the WAF logging stack outputs. | ||
*/ | ||
public class WafLoggingOutputs { | ||
private String kinesisFirehoseDeliveryStreamARN; | ||
|
||
private String kinesisFirehoseDeliveryStreamName; | ||
|
||
public String getKinesisFirehoseDeliveryStreamName() { | ||
return kinesisFirehoseDeliveryStreamName; | ||
} | ||
|
||
public void setKinesisFirehoseDeliveryStreamName(String kinesisFirehoseDeliveryStreamName) { | ||
this.kinesisFirehoseDeliveryStreamName = kinesisFirehoseDeliveryStreamName; | ||
} | ||
|
||
public String getKinesisFirehoseDeliveryStreamARN() { | ||
return kinesisFirehoseDeliveryStreamARN; | ||
} | ||
|
||
public void setKinesisFirehoseDeliveryStreamARN(String kinesisFirehoseDeliveryStreamARN) { | ||
this.kinesisFirehoseDeliveryStreamARN = kinesisFirehoseDeliveryStreamARN; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/nike/cerberus/domain/cloudformation/WafLoggingParameters.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,33 @@ | ||
/* | ||
* Copyright (c) 2020 Nike, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nike.cerberus.domain.cloudformation; | ||
|
||
/** | ||
* Represents the WAF logging stack inputs. | ||
*/ | ||
public class WafLoggingParameters { | ||
private String environmentName; | ||
|
||
public String getEnvironmentName() { | ||
return environmentName; | ||
} | ||
|
||
public WafLoggingParameters setEnvironmentName(String environmentName) { | ||
this.environmentName = environmentName; | ||
return this; | ||
} | ||
} |
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
Oops, something went wrong.