Skip to content
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

Add more rubocop #684

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 93
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'dockerfiles/reverse-proxy/render_template.rb'
- 'lib/barcelona/network/autoscaling_builder.rb'
- 'lib/barcelona/network/bastion_builder.rb'
- 'lib/barcelona/network/nat_builder.rb'
- 'lib/barcelona/network/vpc_builder.rb'
- 'spec/lib/barcelona/network/network_stack_spec.rb'
- 'spec/models/heritage_task_definition_spec.rb'
- 'spec/rails_helper.rb'

# Offense count: 7
# Cop supports --auto-correct.
Layout/HeredocIndentation:
Exclude:
- 'bin/bootstrap'
- 'lib/barcelona/plugins/pcidss_plugin.rb'
- 'lib/tasks/bootstrap.rake'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'spec/models/heritage_spec.rb'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 317

# Offense count: 19
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineArrayBraceLayout:
Exclude:
- 'spec/lib/barcelona/network/network_stack_spec.rb'
- 'spec/models/release_spec.rb'

# Offense count: 3
# Cop supports --auto-correct.
Layout/MultilineBlockLayout:
Exclude:
- 'spec/models/district_spec.rb'
- 'spec/models/heritage_spec.rb'

# Offense count: 124
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineHashBraceLayout:
Exclude:
- 'spec/lib/barcelona/network/network_stack_spec.rb'

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down
30 changes: 15 additions & 15 deletions bin/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ class CLI < Thor
ActiveRecord::Migration.verbose = false

ENV["AWS_REGION"] = options[:region].presence ||
ask_with_description("AWS Region", <<-EOS, default: 'us-east-1')
Choose AWS region you want to deploy Barcelona to.
ask_with_description("AWS Region", <<~EOS, default: 'us-east-1')
Choose AWS region you want to deploy Barcelona to.
EOS

ENV["ACM_CERT_ARN"] = options[:acm_cert_arn].presence ||
ask_with_description("ACM Certificate ARN", <<-EOS, required: false)
Create a new certificate on Amazon Certificate Manager in the region you chose and provide its ARN.
This is optional but we highly recommend setting up an ACM certificate.

Without this certificate your commands will be transmitted to Barcelona using plaintext.
ask_with_description("ACM Certificate ARN", <<~EOS, required: false)
Create a new certificate on Amazon Certificate Manager in the region you chose and provide its ARN.
This is optional but we highly recommend setting up an ACM certificate.
Without this certificate your commands will be transmitted to Barcelona using plaintext.
EOS

ENV["GITHUB_ORGANIZATION"] = options[:github_organization].presence ||
ask_with_description("GitHub Organization", <<-EOS, required: true)
Provide your GitHub organization. Users who belong to this organization
will have access to Barcelona API.
ask_with_description("GitHub Organization", <<~EOS, required: true)
Provide your GitHub organization. Users who belong to this organization
will have access to Barcelona API.
EOS

say <<-EOS, :green
Provide your AWS access key ID and secret access key.
This access key will be used to bootstrap your Barcelona environment.
The best practice is to create a new access key with admin previleges and
delete it after the bootstrap is complete.
say <<~EOS, :green
Provide your AWS access key ID and secret access key.
This access key will be used to bootstrap your Barcelona environment.
The best practice is to create a new access key with admin previleges and
delete it after the bootstrap is complete.
EOS

ENV["AWS_ACCESS_KEY_ID"] = ask("AWS Access Key ID:")
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/reverse-proxy/render_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def log_format
hostname: host,
proxy_protocol: !(ENV['DISABLE_PROXY_PROTOCOL'] == 'true'),
ssl_cert_path: ssl_cert_path,
ssl_key_path: ssl_key_path,
ssl_key_path: ssl_key_path,
force_ssl: ENV['FORCE_SSL'] == 'true',
upstream_name: ENV['UPSTREAM_NAME'],
upstream_port: ENV['UPSTREAM_PORT']
Expand Down
30 changes: 15 additions & 15 deletions lib/barcelona/network/autoscaling_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ class AutoscalingBuilder < CloudFormation::Builder
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html
# amzn2-ami-ecs-hvm-2.0
ECS_OPTIMIZED_AMI_IDS = {
"us-east-1" => "ami-0ae3143bc8c29507d",
"us-east-2" => "ami-01a4986c9e49a5c6a",
"us-west-1" => "ami-0154d362b1af1d7fa",
"us-west-2" => "ami-09821bb7e5aa7e648",
"eu-west-1" => "ami-01ef64c116fe1364f",
"eu-west-2" => "ami-03f4b65c6b7b2e83d",
"eu-west-3" => "ami-0975a74e69d1b66c3",
"eu-central-1" => "ami-00a755f84af357e9e",
"ap-northeast-1" => "ami-0ff8df45400dc4e3d",
"ap-northeast-2" => "ami-019c34e0d65f3727c",
"ap-southeast-1" => "ami-0d242941de637dea8",
"ap-southeast-2" => "ami-03f9a9874affbb05b",
"ca-central-1" => "ami-0617d8461ebdae2b9",
"ap-south-1" => "ami-0b948665b52b6ac61",
"sa-east-1" => "ami-0170497bab30979e8",
"us-east-1" => "ami-0ae3143bc8c29507d",
"us-east-2" => "ami-01a4986c9e49a5c6a",
"us-west-1" => "ami-0154d362b1af1d7fa",
"us-west-2" => "ami-09821bb7e5aa7e648",
"eu-west-1" => "ami-01ef64c116fe1364f",
"eu-west-2" => "ami-03f4b65c6b7b2e83d",
"eu-west-3" => "ami-0975a74e69d1b66c3",
"eu-central-1" => "ami-00a755f84af357e9e",
"ap-northeast-1" => "ami-0ff8df45400dc4e3d",
"ap-northeast-2" => "ami-019c34e0d65f3727c",
"ap-southeast-1" => "ami-0d242941de637dea8",
"ap-southeast-2" => "ami-03f9a9874affbb05b",
"ca-central-1" => "ami-0617d8461ebdae2b9",
"ap-south-1" => "ami-0b948665b52b6ac61",
"sa-east-1" => "ami-0170497bab30979e8",
}

def ebs_optimized_by_default?
Expand Down
30 changes: 15 additions & 15 deletions lib/barcelona/network/bastion_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ class BastionBuilder < CloudFormation::Builder
# You can see the latest version stored in public SSM parameter store
# https://ap-northeast-1.console.aws.amazon.com/systems-manager/parameters/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2/description?region=ap-northeast-1
AMI_IDS = {
"us-east-1" => "ami-0d5eff06f840b45e9",
"us-east-2" => "ami-077e31c4939f6a2f3",
"us-west-1" => "ami-04468e03c37242e1e",
"us-west-2" => "ami-0cf6f5c8a62fa5da6",
"eu-west-1" => "ami-063d4ab14480ac177",
"eu-west-2" => "ami-06dc09bb8854cbde3",
"eu-west-3" => "ami-0b3e57ee3b63dd76b",
"eu-central-1" => "ami-043097594a7df80ec",
"ap-northeast-1" => "ami-0ca38c7440de1749a",
"ap-northeast-2" => "ami-0f2c95e9fe3f8f80e",
"ap-southeast-1" => "ami-02f26adf094f51167",
"ap-southeast-2" => "ami-0186908e2fdeea8f3",
"ca-central-1" => "ami-0101734ab73bd9e15",
"ap-south-1" => "ami-010aff33ed5991201",
"sa-east-1" => "ami-05373777d08895384",
"us-east-1" => "ami-0d5eff06f840b45e9",
"us-east-2" => "ami-077e31c4939f6a2f3",
"us-west-1" => "ami-04468e03c37242e1e",
"us-west-2" => "ami-0cf6f5c8a62fa5da6",
"eu-west-1" => "ami-063d4ab14480ac177",
"eu-west-2" => "ami-06dc09bb8854cbde3",
"eu-west-3" => "ami-0b3e57ee3b63dd76b",
"eu-central-1" => "ami-043097594a7df80ec",
"ap-northeast-1" => "ami-0ca38c7440de1749a",
"ap-northeast-2" => "ami-0f2c95e9fe3f8f80e",
"ap-southeast-1" => "ami-02f26adf094f51167",
"ap-southeast-2" => "ami-0186908e2fdeea8f3",
"ca-central-1" => "ami-0101734ab73bd9e15",
"ap-south-1" => "ami-010aff33ed5991201",
"sa-east-1" => "ami-05373777d08895384",
}

def build_resources
Expand Down
30 changes: 15 additions & 15 deletions lib/barcelona/network/nat_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ class NatBuilder < CloudFormation::Builder
# https://aws.amazon.com/jp/amazon-linux-ami/
# amzn-ami-vpc-nat-hvm
VPC_NAT_AMI_IDS = {
"us-east-1" => "ami-00a9d4a05375b2763",
"us-east-2" => "ami-00d1f8201864cc10c",
"us-west-1" => "ami-097ad469381034fa2",
"us-west-2" => "ami-0b840e8a1ce4cdf15",
"eu-west-1" => "ami-024107e3e3217a248",
"eu-west-2" => "ami-0ca65a55561666293",
"eu-west-3" => "ami-0641e4dfc1427f114",
"eu-central-1" => "ami-06a5303d47fbd8c60",
"ap-northeast-1" => "ami-00d29e4cb217ae06b",
"ap-northeast-2" => "ami-0d98591cbf9ef1ffd",
"ap-southeast-1" => "ami-01514bb1776d5c018",
"ap-southeast-2" => "ami-062c04ec46aecd204",
"ca-central-1" => "ami-0b32354309da5bba5",
"ap-south-1" => "ami-00b3aa8a93dd09c13",
"sa-east-1" => "ami-057f5d52ff7ae75ae",
"us-east-1" => "ami-00a9d4a05375b2763",
"us-east-2" => "ami-00d1f8201864cc10c",
"us-west-1" => "ami-097ad469381034fa2",
"us-west-2" => "ami-0b840e8a1ce4cdf15",
"eu-west-1" => "ami-024107e3e3217a248",
"eu-west-2" => "ami-0ca65a55561666293",
"eu-west-3" => "ami-0641e4dfc1427f114",
"eu-central-1" => "ami-06a5303d47fbd8c60",
"ap-northeast-1" => "ami-00d29e4cb217ae06b",
"ap-northeast-2" => "ami-0d98591cbf9ef1ffd",
"ap-southeast-1" => "ami-01514bb1776d5c018",
"ap-southeast-2" => "ami-062c04ec46aecd204",
"ca-central-1" => "ami-0b32354309da5bba5",
"ap-south-1" => "ami-00b3aa8a93dd09c13",
"sa-east-1" => "ami-057f5d52ff7ae75ae",
}

def build_resources
Expand Down
20 changes: 10 additions & 10 deletions lib/barcelona/network/vpc_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ module Barcelona
module Network
# https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html
ELB_ACCOUNT_IDS = {
"us-east-1" => "127311923021",
"us-east-2" => "033677994240",
"us-west-1" => "027434742980",
"us-west-2" => "797873946194",
"ca-central-1" => "985666609251",
"eu-west-1" => "156460612806",
"eu-central-1" => "054676820928",
"eu-west-2" => "652711504416",
"us-east-1" => "127311923021",
"us-east-2" => "033677994240",
"us-west-1" => "027434742980",
"us-west-2" => "797873946194",
"ca-central-1" => "985666609251",
"eu-west-1" => "156460612806",
"eu-central-1" => "054676820928",
"eu-west-2" => "652711504416",
"ap-northeast-1" => "582318560864",
"ap-northeast-2" => "600734575887",
"ap-southeast-1" => "114774131450",
"ap-southeast-2" => "783225319266",
"ap-south-1" => "718504428378",
"sa-east-1" => "507241528517"
"ap-south-1" => "718504428378",
"sa-east-1" => "507241528517"
}

class VPCBuilder < CloudFormation::Builder
Expand Down
36 changes: 18 additions & 18 deletions lib/barcelona/plugins/pcidss_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,15 @@ def run_commands
def on_container_instance_user_data(_instance, user_data)
user_data.run_commands += run_commands

user_data.add_file("/etc/yum.repos.d/wazuh.repo", "root:root", "644", <<EOS)
[wazuh_repo]
gpgcheck=1
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=Wazuh
baseurl=https://packages.wazuh.com/yum/el/7/x86_64
protect=1
EOS
user_data.add_file("/etc/yum.repos.d/wazuh.repo", "root:root", "644", <<~EOS)
[wazuh_repo]
gpgcheck=1
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=Wazuh
baseurl=https://packages.wazuh.com/yum/el/7/x86_64
protect=1
EOS
user_data
end

Expand All @@ -436,15 +436,15 @@ def on_network_stack_template(_stack, template)

user_data = InstanceUserData.load_or_initialize(bastion_lc["Properties"]["UserData"])
user_data.run_commands += run_commands
user_data.add_file("/etc/yum.repos.d/wazuh.repo", "root:root", "644", <<EOS)
[wazuh_repo]
gpgcheck=1
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=Wazuh
baseurl=https://packages.wazuh.com/yum/el/7/x86_64
protect=1
EOS
user_data.add_file("/etc/yum.repos.d/wazuh.repo", "root:root", "644", <<~EOS)
[wazuh_repo]
gpgcheck=1
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=Wazuh
baseurl=https://packages.wazuh.com/yum/el/7/x86_64
protect=1
EOS
bastion_lc["Properties"]["UserData"] = user_data.build
template
end
Expand Down
12 changes: 6 additions & 6 deletions lib/tasks/bootstrap.rake
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ namespace :bcn do
heritage.destroy!

puts
puts <<-EOS
Barcelona Bootstrap Completed!
Endpoint: #{dns_name}

Set your DNS record to point to the above endpoint and run the following Barcelona client command
$ bcn login https://<your barcelona domain> <GitHub Token>
puts <<~EOS
Barcelona Bootstrap Completed!
Endpoint: #{dns_name}
Set your DNS record to point to the above endpoint and run the following Barcelona client command
$ bcn login https://<your barcelona domain> <GitHub Token>
EOS
end

Expand Down
Loading