Skip to content

Commit

Permalink
Merge branch 'main' into rate-limit-redis
Browse files Browse the repository at this point in the history
  • Loading branch information
philippthun authored Jul 3, 2023
2 parents 8ea2f0d + 1750fec commit c9033ac
Show file tree
Hide file tree
Showing 28 changed files with 335 additions and 73 deletions.
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ gem 'vmstat', '~> 2.3'
gem 'yajl-ruby'

# Rails Components
gem 'actionpack', '~> 6.1.7', '>= 6.1.7.3'
gem 'actionpack', '~> 6.1.7'
gem 'actionview', '~> 6.1.7', '>= 6.1.7.3'
gem 'activemodel', '~> 6.1.7'
gem 'railties', '~> 6.1.7', '>= 6.1.7.3'
Expand All @@ -61,7 +61,7 @@ gem 'azure-storage-blob', git: 'https://github.com/sethboyles/azure-storage-ruby
gem 'fog-aliyun'
gem 'fog-aws'
gem 'fog-azure-rm', git: 'https://github.com/fog/fog-azure-rm.git', branch: 'fog-arm-cf'
gem 'fog-google', '~> 1.20.0'
gem 'fog-google', '~> 1.21.1'
gem 'fog-local'
gem 'fog-openstack'
gem 'fog-core', '~> 2.1.2'
Expand All @@ -75,7 +75,6 @@ group :db do
end

group :operations do
gem 'awesome_print'
gem 'pry-byebug'
end

Expand All @@ -91,7 +90,7 @@ group :test do
gem 'rspec-rails', '~> 6.0.3'
gem 'rspec-wait'
gem 'rspec_api_documentation', '>= 6.1.0'
gem 'rubocop', '~> 1.52.1'
gem 'rubocop', '~> 1.53.1'
gem 'timecop'
gem 'webmock', '> 2.3.1'
end
Expand Down
57 changes: 29 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionpack (6.1.7.3)
actionview (= 6.1.7.3)
activesupport (= 6.1.7.3)
actionpack (6.1.7.4)
actionview (= 6.1.7.4)
activesupport (= 6.1.7.4)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.1.7.3)
activesupport (= 6.1.7.3)
actionview (6.1.7.4)
activesupport (= 6.1.7.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activemodel (6.1.7.3)
activesupport (= 6.1.7.3)
activesupport (6.1.7.3)
activemodel (6.1.7.4)
activesupport (= 6.1.7.4)
activesupport (6.1.7.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -79,7 +79,6 @@ GEM
activesupport (>= 3.2)
i18n
ast (2.4.2)
awesome_print (1.9.2)
azure-core (0.1.15)
faraday (~> 0.9)
faraday_middleware (~> 0.10)
Expand Down Expand Up @@ -174,7 +173,8 @@ GEM
excon (~> 0.58)
formatador (~> 0.2)
mime-types
fog-google (1.20.0)
fog-google (1.21.1)
addressable (>= 2.7.0)
fog-core (< 2.3)
fog-json (~> 1.2)
fog-xml (~> 0.1.0)
Expand All @@ -184,7 +184,7 @@ GEM
google-apis-monitoring_v3 (~> 0.37)
google-apis-pubsub_v1 (~> 0.30)
google-apis-sqladmin_v1beta4 (~> 0.38)
google-apis-storage_v1 (~> 0.20)
google-apis-storage_v1 (>= 0.19, < 1)
google-cloud-env (~> 1.2)
fog-json (1.2.0)
fog-core
Expand All @@ -198,7 +198,7 @@ GEM
fog-core
nokogiri (>= 1.5.11, < 2.0.0)
formatador (0.3.0)
google-apis-compute_v1 (0.66.0)
google-apis-compute_v1 (0.71.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.0)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -213,11 +213,11 @@ GEM
google-apis-core (>= 0.11.0, < 2.a)
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-monitoring_v3 (0.44.0)
google-apis-monitoring_v3 (0.46.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-pubsub_v1 (0.35.0)
google-apis-pubsub_v1 (0.38.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-sqladmin_v1beta4 (0.47.0)
google-apis-sqladmin_v1beta4 (0.50.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.22.0)
google-apis-core (>= 0.11.0, < 2.a)
Expand Down Expand Up @@ -262,7 +262,7 @@ GEM
http-form_data (2.3.0)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (1.13.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
jaro_winkler (1.5.4)
Expand All @@ -273,7 +273,7 @@ GEM
json_pure (2.6.3)
jsonpath (1.1.2)
multi_json
jwt (2.7.0)
jwt (2.7.1)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
Expand All @@ -283,6 +283,7 @@ GEM
jsonpath (~> 1.0)
recursive-open-struct (~> 1.1, >= 1.1.1)
rest-client (~> 2.0)
language_server-protocol (3.17.0.3)
libhoney (2.2.0)
addressable (~> 2.0)
excon
Expand All @@ -307,7 +308,7 @@ GEM
mime-types-data (3.2023.0218.1)
mini_mime (1.1.2)
mini_portile2 (2.8.2)
minitest (5.18.0)
minitest (5.18.1)
mock_redis (0.34.0)
ruby2_keywords
ms_rest (0.6.4)
Expand All @@ -330,7 +331,7 @@ GEM
net-ssh (7.1.0)
netaddr (2.0.6)
netrc (0.11.0)
newrelic_rpm (9.2.2)
newrelic_rpm (9.3.0)
nio4r (2.5.8)
nokogiri (1.15.2)
mini_portile2 (~> 2.8.2)
Expand Down Expand Up @@ -362,7 +363,7 @@ GEM
public_suffix (5.0.1)
puma (5.6.5)
nio4r (~> 2.0)
racc (1.6.2)
racc (1.7.1)
rack (2.2.7)
rack-protection (3.0.6)
rack
Expand All @@ -374,9 +375,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (6.1.7.3)
actionpack (= 6.1.7.3)
activesupport (= 6.1.7.3)
railties (6.1.7.4)
actionpack (= 6.1.7.4)
activesupport (= 6.1.7.4)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down Expand Up @@ -443,8 +444,9 @@ GEM
activesupport (>= 3.0.0)
mustache (~> 1.0, >= 0.99.4)
rspec (~> 3.0)
rubocop (1.52.1)
rubocop (1.53.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
Expand Down Expand Up @@ -550,12 +552,11 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
actionpack (~> 6.1.7, >= 6.1.7.3)
actionpack (~> 6.1.7)
actionview (~> 6.1.7, >= 6.1.7.3)
activemodel (~> 6.1.7)
addressable
allowy (>= 2.1.0)
awesome_print
azure-storage-blob!
byebug
cf-copilot (= 0.0.14)
Expand All @@ -570,7 +571,7 @@ DEPENDENCIES
fog-aws
fog-azure-rm!
fog-core (~> 2.1.2)
fog-google (~> 1.20.0)
fog-google (~> 1.21.1)
fog-local
fog-openstack
googleapis-common-protos (>= 1.3.12)
Expand Down Expand Up @@ -618,7 +619,7 @@ DEPENDENCIES
rspec-rails (~> 6.0.3)
rspec-wait
rspec_api_documentation (>= 6.1.0)
rubocop (~> 1.52.1)
rubocop (~> 1.53.1)
rubyzip (>= 1.3.0)
sequel (~> 5.69)
sequel_pg
Expand Down
42 changes: 30 additions & 12 deletions app/messages/resource_match_create_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,72 @@ def v2_fingerprints_body

private

PERMISSIONS_REGEX = /^[0-7]{3,4}$/

def each_resource
if resources.is_a?(Array)
resources.each do |r|
checksum_validator(r[:checksum])
size_validator(r[:size_in_bytes])
mode_validator(r[:mode])
end
end
end

RESOURCE_ERROR_PREAMBLE = 'array contains at least one resource with a'.freeze
RESOURCE_ERROR_PREAMBLE = 'array contains at least one resource with'.freeze

def checksum_validator(checksum)
unless checksum.is_a?(Hash)
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} non-object checksum") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} non-object checksum"
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-object checksum") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-object checksum"
)
return
end

unless checksum[:value].is_a?(String)
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} non-string checksum value") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} non-string checksum value"
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-string checksum value") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-string checksum value"
)
return
end

unless valid_sha1?(checksum[:value])
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} non-SHA1 checksum value") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} non-SHA1 checksum value"
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-SHA1 checksum value") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-SHA1 checksum value"
)
return
end
end

def size_validator(size)
unless size.is_a?(Integer)
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} non-integer size_in_bytes") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} non-integer size_in_bytes"
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-integer size_in_bytes") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-integer size_in_bytes"
)
return
end

unless size >= 0
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} negative size_in_bytes") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} negative size_in_bytes"
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a negative size_in_bytes") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} a negative size_in_bytes"
)
end
end

def mode_validator(mode)
return if mode.nil?

unless mode.is_a?(String)
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-string mode") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-string mode"
)
return
end

unless PERMISSIONS_REGEX.match?(mode)
errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} an incorrect mode") unless errors.added?(
:resources, "#{RESOURCE_ERROR_PREAMBLE} an incorrect mode"
)
end
end

def valid_sha1?(value)
Expand Down
16 changes: 13 additions & 3 deletions app/models/runtime/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class AppsStillPresentError < StandardError

plugin :serialization

export_attributes :name, :description
import_attributes :name, :description
export_attributes :name, :description, :build_rootfs_image, :run_rootfs_image
import_attributes :name, :description, :build_rootfs_image, :run_rootfs_image

strip_attributes :name

Expand All @@ -47,6 +47,14 @@ def default?
false
end

def build_rootfs_image
super || self.name
end

def run_rootfs_image
super || self.name
end

def self.configure(file_path)
@config_file = if file_path
ConfigFile.new(file_path)
Expand Down Expand Up @@ -83,7 +91,7 @@ def self.populate_from_hash(hash)
Steno.logger('cc.stack').warn('stack.populate.collision', hash)
end
else
create(hash.slice('name', 'description'))
create(hash.slice('name', 'description', 'build_rootfs_image', 'run_rootfs_image'))
end
end

Expand All @@ -108,6 +116,8 @@ def default
'stacks' => [{
'name' => String,
'description' => String,
optional('build_rootfs_image') => String,
optional('run_rootfs_image') => String,
}]
}
end
Expand Down
1 change: 1 addition & 0 deletions app/presenters/v3/process_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def to_hash
guid: process.guid,
created_at: process.created_at,
updated_at: process.updated_at,
version: process.version,
type: process.type,
command: redact(process.specified_or_detected_command),
instances: process.instances,
Expand Down
2 changes: 1 addition & 1 deletion config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.140.0
3.141.0
2 changes: 1 addition & 1 deletion config/version_v2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.205.0
2.206.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Sequel.migration do
up do
alter_table :stacks do
add_column :build_rootfs_image, String, size: 255
add_column :run_rootfs_image, String, size: 255
end
end

down do
alter_table :stacks do
drop_column :build_rootfs_image
drop_column :run_rootfs_image
end
end
end
2 changes: 1 addition & 1 deletion docs/v2/info/get_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ <h4>Body</h4>
"token_endpoint": "http://localhost:8080/uaa",
"min_cli_version": null,
"min_recommended_cli_version": null,
"api_version": "2.205.0",
"api_version": "2.206.0",
"app_ssh_endpoint": "ssh.system.domain.example.com:2222",
"app_ssh_host_key_fingerprint": "47:0d:d1:c8:c3:3d:0a:36:d1:49:2f:f2:90:27:31:d0",
"app_ssh_oauth_client": null,
Expand Down
Loading

0 comments on commit c9033ac

Please sign in to comment.