Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit b5f7540

Browse files
authored
Merge branch 'master' into snyk-fix-8a7055fff721e53f29f0d76c4643a85c
2 parents 42005c2 + 7fbb822 commit b5f7540

600 files changed

Lines changed: 15042 additions & 4890 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ ratings:
4343
- "**.sh"
4444
exclude_paths:
4545
- docs/v3/node_modules/
46-
- vendor/
46+
- errors/

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: '11:00'
8+
open-pull-requests-limit: 100
9+
- package-ecosystem: bundler
10+
directory: "/docs/v3"
11+
schedule:
12+
interval: daily
13+
time: '11:00'
14+
open-pull-requests-limit: 10
15+
- package-ecosystem: npm
16+
directory: "/docs/v3"
17+
schedule:
18+
interval: daily
19+
time: '11:00'
20+
open-pull-requests-limit: 10

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require:
77
AllCops:
88
TargetRubyVersion: 2.5
99
Exclude:
10-
- vendor/**/*
10+
- errors/**/*
1111
- lib/diego/bbs/models/**/*
1212
- lib/logcache/v2/**/*
1313

.snyk

Lines changed: 0 additions & 9 deletions
This file was deleted.

.solargraph.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
include:
33
- "**/*.rb"
44
exclude:
5-
- spec/**/*
65
- test/**/*
7-
- vendor/**/*
6+
- errors/**/*
87
- ".bundle/**/*"
98
require: []
109
domains: []

.vim/coc-settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"solargraph.symbols": true,
3+
"solargraph.definitions": true,
4+
"solargraph.references": true
5+
}

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ gem 'clockwork', require: false
77
gem 'cloudfront-signer'
88
gem 'em-http-request', '~> 1.1'
99
gem 'eventmachine', '~> 1.0.9'
10+
gem 'fluent-logger'
1011
gem 'googleapis-common-protos'
1112
gem 'hashdiff'
1213
gem 'httpclient'
14+
gem 'json-diff'
1315
gem 'json-schema'
1416
gem 'json_pure'
1517
gem 'kubeclient'

Gemfile.lock

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ GEM
5757
tzinfo (~> 1.1)
5858
addressable (2.6.0)
5959
public_suffix (>= 2.0.2, < 4.0)
60+
aliyun-sdk (0.7.3)
61+
nokogiri (~> 1.6)
62+
rest-client (~> 2.0)
6063
allowy (2.1.0)
6164
activesupport (>= 3.2)
6265
i18n
63-
ast (2.4.0)
66+
ast (2.4.1)
6467
awesome_print (1.8.0)
6568
azure-core (0.1.14)
6669
faraday (~> 0.9)
@@ -87,9 +90,10 @@ GEM
8790
ms_rest_azure (~> 0.7.0)
8891
azure_mgmt_traffic_manager (0.9.0)
8992
ms_rest_azure (~> 0.7.0)
90-
backport (1.1.1)
93+
backport (1.1.2)
9194
backports (3.11.4)
9295
beefcake (1.0.0)
96+
benchmark (0.1.0)
9397
bit-struct (0.16)
9498
bits_service_client (3.4.0)
9599
activesupport
@@ -130,6 +134,7 @@ GEM
130134
docile (1.1.5)
131135
domain_name (0.5.20180417)
132136
unf (>= 0.0.5, < 1.0.0)
137+
e2mmap (0.1.0)
133138
em-http-request (1.1.5)
134139
addressable (>= 2.3.4)
135140
cookiejar (!= 0.3.1)
@@ -154,7 +159,8 @@ GEM
154159
rake
155160
fluent-logger (0.8.2)
156161
msgpack (>= 1.0.0, < 2)
157-
fog-aliyun (0.3.10)
162+
fog-aliyun (0.3.17)
163+
aliyun-sdk (~> 0.7.3)
158164
fog-core
159165
fog-json
160166
ipaddress (~> 0.8)
@@ -220,7 +226,6 @@ GEM
220226
google-protobuf (~> 3.1)
221227
googleapis-common-protos-types (~> 1.0.0)
222228
hashdiff (0.3.8)
223-
htmlentities (4.3.4)
224229
http (4.2.0)
225230
addressable (~> 2.3)
226231
http-cookie (~> 1.0)
@@ -239,11 +244,11 @@ GEM
239244
ipaddress (0.8.3)
240245
jaro_winkler (1.5.4)
241246
json (2.3.0)
247+
json-diff (0.4.1)
242248
json-schema (2.8.0)
243249
addressable (>= 2.4)
244250
json_pure (2.1.0)
245251
jwt (2.2.1)
246-
kramdown (1.17.0)
247252
kubeclient (4.5.0)
248253
http (>= 3.0, < 5.0)
249254
recursive-open-struct (~> 1.0, >= 1.0.4)
@@ -258,6 +263,7 @@ GEM
258263
crass (~> 1.0.2)
259264
nokogiri (>= 1.5.9)
260265
machinist (1.0.6)
266+
maruku (0.7.3)
261267
membrane (1.1.0)
262268
memoist (0.16.0)
263269
method_source (0.9.2)
@@ -294,7 +300,7 @@ GEM
294300
parallel (1.19.1)
295301
parallel_tests (2.27.1)
296302
parallel
297-
parser (2.7.0.2)
303+
parser (2.7.1.3)
298304
ast (~> 2.4.0)
299305
pg (1.0.0)
300306
posix-spawn (0.3.13)
@@ -310,7 +316,7 @@ GEM
310316
byebug (~> 10.0)
311317
pry (~> 0.10)
312318
public_suffix (3.1.0)
313-
rack (2.2.2)
319+
rack (2.2.3)
314320
rack-protection (2.0.5)
315321
rack
316322
rack-test (1.1.0)
@@ -342,7 +348,7 @@ GEM
342348
mime-types (>= 1.16, < 4.0)
343349
netrc (~> 0.8)
344350
retriable (3.1.2)
345-
reverse_markdown (1.1.0)
351+
reverse_markdown (2.0.0)
346352
nokogiri
347353
rfc822 (0.1.5)
348354
roodi (5.0.0)
@@ -422,18 +428,20 @@ GEM
422428
rack-protection (= 2.0.5)
423429
sinatra (= 2.0.5)
424430
tilt (>= 1.3, < 3)
425-
solargraph (0.34.3)
431+
solargraph (0.39.8)
426432
backport (~> 1.1)
433+
benchmark
427434
bundler (>= 1.17.2)
428-
htmlentities (~> 4.3, >= 4.3.4)
435+
e2mmap
429436
jaro_winkler (~> 1.5)
430-
kramdown (~> 1.16)
437+
maruku (~> 0.7, >= 0.7.3)
438+
nokogiri (~> 1.9, >= 1.9.1)
431439
parser (~> 2.3)
432-
reverse_markdown (~> 1.0, >= 1.0.5)
440+
reverse_markdown (>= 1.0.5, < 3)
433441
rubocop (~> 0.52)
434-
thor (~> 0.19, >= 0.19.4)
442+
thor (~> 1.0)
435443
tilt (~> 2.0)
436-
yard (~> 0.9)
444+
yard (~> 0.9, >= 0.9.24)
437445
spring (2.1.0)
438446
spring-commands-rspec (1.0.4)
439447
spring (>= 0.9.1)
@@ -450,11 +458,11 @@ GEM
450458
daemons (~> 1.0, >= 1.0.9)
451459
eventmachine (~> 1.0, >= 1.0.4)
452460
rack (>= 1, < 3)
453-
thor (0.20.3)
461+
thor (1.0.1)
454462
thread_safe (0.3.6)
455-
tilt (2.0.9)
463+
tilt (2.0.10)
456464
timecop (0.9.1)
457-
timeliness (0.3.8)
465+
timeliness (0.3.10)
458466
tzinfo (1.2.7)
459467
thread_safe (~> 0.1)
460468
uber (0.1.0)
@@ -471,7 +479,7 @@ GEM
471479
hashdiff
472480
xml-simple (1.1.5)
473481
yajl-ruby (1.4.1)
474-
yard (0.9.20)
482+
yard (0.9.25)
475483

476484
PLATFORMS
477485
ruby
@@ -500,6 +508,7 @@ DEPENDENCIES
500508
debase (>= 0.2.2.beta14)
501509
em-http-request (~> 1.1)
502510
eventmachine (~> 1.0.9)
511+
fluent-logger
503512
fog-aliyun
504513
fog-aws
505514
fog-azure-rm!
@@ -509,6 +518,7 @@ DEPENDENCIES
509518
googleapis-common-protos
510519
hashdiff
511520
httpclient
521+
json-diff
512522
json-schema
513523
json_pure
514524
kubeclient

app/actions/app_apply_manifest.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
module VCAP::CloudController
1111
class AppApplyManifest
12+
class Error < StandardError; end
1213
class NoDefaultDomain < StandardError; end
1314
class ServiceBindingError < StandardError; end
1415

@@ -105,6 +106,7 @@ def update_routes(app, message)
105106
end
106107

107108
if update_message.default_route && existing_routes.empty?
109+
validate_name_dns_compliant!(app.name)
108110
domain_name = get_default_domain_name(app)
109111

110112
route = "#{app.name}.#{domain_name}"
@@ -121,6 +123,18 @@ def get_default_domain_name(app)
121123
domain_name
122124
end
123125

126+
def validate_name_dns_compliant!(name)
127+
prefix = 'Failed to create default route from app name:'
128+
129+
if name.present? && name.length > 63
130+
error!(prefix + ' Host cannot exceed 63 characters')
131+
end
132+
133+
unless name&.match(/\A[\w\-]+\z/)
134+
error!(prefix + ' Host must be either "*" or contain only alphanumeric characters, "_", or "-"')
135+
end
136+
end
137+
124138
def create_service_bindings(manifest_service_bindings_message, app)
125139
action = ServiceBindingCreate.new(@user_audit_info, manifest_triggered: true)
126140
manifest_service_bindings_message.manifest_service_bindings.each do |manifest_service_binding|
@@ -162,5 +176,9 @@ def volume_services_enabled?
162176
def logger
163177
@logger ||= Steno.logger('cc.action.app_apply_manifest')
164178
end
179+
180+
def error!(message)
181+
raise Error.new(message)
182+
end
165183
end
166184
end

app/actions/app_create.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
require 'process_create'
22
require 'models/helpers/process_types'
33
require 'actions/labels_update'
4+
require 'cloud_controller/errors/api_error_helpers'
45

56
module VCAP::CloudController
67
class AppCreate
8+
include CloudController::Errors::ApiErrorHelpers
9+
710
class InvalidApp < StandardError; end
811

912
def initialize(user_audit_info)
@@ -21,10 +24,11 @@ def create(message, lifecycle)
2124
)
2225

2326
lifecycle.create_lifecycle_data_model(app)
27+
validate_buildpacks_are_ready(app)
2428

2529
MetadataUpdate.update(app, message)
2630

27-
raise CloudController::Errors::ApiError.new_from_details('CustomBuildpacksDisabled') if using_disabled_custom_buildpack?(app)
31+
api_error!(:CustomBuildpacksDisabled) if using_disabled_custom_buildpack?(app)
2832

2933
ProcessCreate.new(@user_audit_info).create(app, {
3034
guid: app.guid,
@@ -41,6 +45,10 @@ def create(message, lifecycle)
4145

4246
app
4347
rescue Sequel::ValidationFailed => e
48+
if e.errors.on([:space_guid, :name])
49+
v3_api_error!(:UniquenessError, e.message)
50+
end
51+
4452
raise InvalidApp.new(e.message)
4553
end
4654

@@ -53,5 +61,20 @@ def using_disabled_custom_buildpack?(app)
5361
def custom_buildpacks_disabled?
5462
VCAP::CloudController::Config.config.get(:disable_custom_buildpacks)
5563
end
64+
65+
def validate_buildpacks_are_ready(app)
66+
return unless app.buildpack_lifecycle_data
67+
68+
app.buildpack_lifecycle_data.buildpack_lifecycle_buildpacks.each do |blb|
69+
unless blb.custom?
70+
buildpack = Buildpack.find(name: blb.admin_buildpack_name)
71+
72+
if buildpack && buildpack.state != Buildpack::READY_STATE
73+
raise InvalidApp.new("#{buildpack.name.inspect} must be in ready state")
74+
# errors.add(:buildpack, "#{buildpack.name.inspect} must be in ready state")
75+
end
76+
end
77+
end
78+
end
5679
end
5780
end

0 commit comments

Comments
 (0)