Skip to content

Commit 349e93b

Browse files
committed
Merge branch '741-synopsys-seeker'
Signed-off-by: Ben Hale <[email protected]>
2 parents a2dd394 + 8ad0be0 commit 349e93b

File tree

7 files changed

+180
-0
lines changed

7 files changed

+180
-0
lines changed

.idea/dictionaries/bhale.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ The buildpack supports extension through the use of Git repository forking. The
105105
* [PostgreSQL JDBC](docs/framework-postgresql_jdbc.md) ([Configuration](docs/framework-postgresql_jdbc.md#configuration))
106106
* [ProtectApp Security Provider](docs/framework-protect_app_security_provider.md) ([Configuration](docs/framework-protect_app_security_provider.md#configuration))
107107
* [Riverbed AppInternals Agent](docs/framework-riverbed_appinternals_agent.md) ([Configuration](docs/framework-riverbed_appinternals_agent.md#configuration))
108+
* [Seeker Security Provider](docs/framework-seeker_security_provider.md) ([Configuration](docs/framework-seeker_security_provider.md#configuration))
108109
* [Spring Auto Reconfiguration](docs/framework-spring_auto_reconfiguration.md) ([Configuration](docs/framework-spring_auto_reconfiguration.md#configuration))
109110
* [Spring Insight](docs/framework-spring_insight.md)
110111
* [SkyWalking Agent](docs/framework-sky_walking_agent.md) ([Configuration](docs/framework-sky_walking_agent.md#configuration))

config/components.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ frameworks:
6666
- "JavaBuildpack::Framework::PostgresqlJDBC"
6767
- "JavaBuildpack::Framework::ProtectAppSecurityProvider"
6868
- "JavaBuildpack::Framework::RiverbedAppinternalsAgent"
69+
- "JavaBuildpack::Framework::SeekerSecurityProvider"
6970
- "JavaBuildpack::Framework::SpringAutoReconfiguration"
7071
- "JavaBuildpack::Framework::SpringInsight"
7172
- "JavaBuildpack::Framework::SkyWalkingAgent"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Seeker Security Provider Framework
2+
The Seeker Security Provider Framework causes an application to be bound with a [Seeker Security Provider][s] service instance.
3+
4+
<table>
5+
<tr>
6+
<td><strong>Detection Criterion</strong></td><td>Existence of a single bound Seeker Security Provider service. The existence of a provider service is defined by the <a href="http://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES"><code>VCAP_SERVICES</code></a> payload containing a service name, label or tag with <code>seeker</code> as a substring.
7+
</td>
8+
</tr>
9+
<tr>
10+
<td><strong>Tags</strong></td>
11+
<td><tt>seeker-service-provider</tt></td>
12+
</tr>
13+
</table>
14+
Tags are printed to standard output by the buildpack detect script
15+
16+
## User-Provided Service
17+
When binding Appinternals using a user-provided service, it must have <code>seeker</code> as substring. The credential payload must contain the following entries:
18+
19+
| Name | Description
20+
| ---- | -----------
21+
| `seeker_server_url` | The fully qualified URL of a Synopsys Seeker Server (e.g. `https://seeker.example.com`)
22+
23+
**NOTE**
24+
In order to use this integration, the Seeker Server version must be at least `2019.08` or later.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# frozen_string_literal: true
2+
3+
# Cloud Foundry Java Buildpack
4+
# Copyright 2013-2017 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
require 'java_buildpack/component/base_component'
19+
require 'java_buildpack/framework'
20+
require 'java_buildpack/util/dash_case'
21+
22+
module JavaBuildpack
23+
module Framework
24+
25+
# Encapsulates the functionality for enabling zero-touch Seeker support.
26+
class SeekerSecurityProvider < JavaBuildpack::Component::BaseComponent
27+
28+
# Creates an instance
29+
#
30+
# @param [Hash] context a collection of utilities used the component
31+
def initialize(context)
32+
super(context)
33+
34+
@uri = download_url(credentials) if supports?
35+
end
36+
37+
# (see JavaBuildpack::Component::BaseComponent#detect)
38+
def detect
39+
@uri ? self.class.to_s.dash_case : nil
40+
end
41+
42+
# (see JavaBuildpack::Component::BaseComponent#compile)
43+
def compile
44+
JavaBuildpack::Util::Cache::InternetAvailability.instance.available(
45+
true, 'Downloading from Synopsys Seeker Server'
46+
) do
47+
download_zip('', @uri, false, @droplet.sandbox, @component_name)
48+
end
49+
@droplet.copy_resources
50+
rescue StandardError => e
51+
raise "Synopsys Seeker download failed: #{e}"
52+
end
53+
54+
# (see JavaBuildpack::Component::BaseComponent#release)
55+
def release
56+
c = credentials
57+
58+
@droplet.java_opts.add_javaagent(@droplet.sandbox + 'seeker-agent.jar')
59+
@droplet.environment_variables
60+
.add_environment_variable('SEEKER_SERVER_URL', c[SEEKER_SERVER_URL_CONFIG_KEY])
61+
end
62+
63+
private
64+
65+
# Relative path of the agent zip
66+
AGENT_PATH = '/rest/api/latest/installers/agents/binaries/JAVA'
67+
68+
# seeker service name identifier
69+
FILTER = /seeker/i.freeze
70+
71+
# JSON key for the address of seeker sensor
72+
SEEKER_SERVER_URL_CONFIG_KEY = 'seeker_server_url'
73+
74+
private_constant :AGENT_PATH, :FILTER, :SEEKER_SERVER_URL_CONFIG_KEY
75+
76+
def credentials
77+
@application.services.find_service(FILTER, SEEKER_SERVER_URL_CONFIG_KEY)['credentials']
78+
end
79+
80+
def download_url(credentials)
81+
"#{credentials[SEEKER_SERVER_URL_CONFIG_KEY]}#{AGENT_PATH}"
82+
end
83+
84+
def supports?
85+
@application.services.one_service?(FILTER, SEEKER_SERVER_URL_CONFIG_KEY)
86+
end
87+
88+
end
89+
90+
end
91+
92+
end

spec/fixtures/stub-seeker-agent.zip

414 Bytes
Binary file not shown.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# frozen_string_literal: true
2+
3+
# Cloud Foundry Java Buildpack
4+
# Copyright 2013-2018 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
require 'spec_helper'
19+
require 'component_helper'
20+
require 'java_buildpack/framework/seeker_security_provider'
21+
22+
describe JavaBuildpack::Framework::SeekerSecurityProvider do
23+
include_context 'with component help'
24+
25+
it 'does not detect without seeker service' do
26+
expect(component.detect).to be_nil
27+
end
28+
29+
context do
30+
31+
before do
32+
allow(services).to receive(:one_service?).with(/seeker/i, 'seeker_server_url').and_return(true)
33+
34+
allow(services).to receive(:find_service).and_return('credentials' => { 'seeker_server_url' =>
35+
'http://localhost' })
36+
37+
allow(application_cache).to receive(:get).with('http://localhost/rest/api/latest/installers/agents/binaries/JAVA')
38+
.and_yield(Pathname.new('spec/fixtures/stub-seeker-agent.zip').open,
39+
false)
40+
end
41+
42+
it 'detects with seeker service' do
43+
expect(component.detect).to eq('seeker-security-provider')
44+
end
45+
46+
it 'expands Seeker agent zip for agent direct download' do
47+
component.compile
48+
49+
expect(sandbox + 'seeker-agent.jar').to exist
50+
end
51+
52+
it 'updates JAVA_OPTS' do
53+
component.release
54+
55+
expect(java_opts).to include('-javaagent:$PWD/.java-buildpack/seeker_security_provider/seeker-agent.jar')
56+
expect(environment_variables).to include('SEEKER_SERVER_URL=http://localhost')
57+
end
58+
59+
end
60+
61+
end

0 commit comments

Comments
 (0)