Skip to content

Commit 927db83

Browse files
authored
Merge pull request #7 from safedep/develop
OpenSearch Indexing
2 parents 9e04d54 + 7e4aecf commit 927db83

31 files changed

Lines changed: 719 additions & 338 deletions

.github/workflows/codeql.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
name: "CodeQL"
22

33
on:
4-
push:
5-
branches: [ "main" ]
64
pull_request:
75
branches: [ "main" ]
8-
schedule:
9-
- cron: '55 23 * * 0'
106

117
jobs:
128
analyze:

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ jobs:
1818
uses: actions/checkout@v3
1919
- name: 'Dependency Review'
2020
uses: actions/dependency-review-action@v2
21+
with:
22+
fail-on-severity: high

README.md

Lines changed: 11 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
# Supply Chain Security Gateway
2-
3-
A reference architecture and **<ins>proof of concept implementation</ins>** of a supply chain security gateway with the goal of enforcing sane security policies to an organization's consumption of 3rd party software (dependencies) in its own products.
4-
5-
- [Supply Chain Security Gateway](#supply-chain-security-gateway)
6-
- [TL;DR](#tldr)
7-
- [Architecture](#architecture)
8-
- [Data Plane Flow](#data-plane-flow)
9-
- [Usage](#usage)
10-
- [Configuring Upstream and Routes](#configuring-upstream-and-routes)
11-
- [Configuring Environments](#configuring-environments)
12-
- [Authentication](#authentication)
13-
- [Ingress Authentication](#ingress-authentication)
14-
- [Basic Authentication](#basic-authentication)
15-
- [Development](#development)
16-
- [PDP Development](#pdp-development)
17-
- [Policy Development](#policy-development)
18-
- [Tap Development](#tap-development)
19-
- [Debug NATS Messaging](#debug-nats-messaging)
20-
- [Contribution](#contribution)
1+
# SafeDep: Security Gateway
2+
3+
Security gateway can be used to establish policy control over consumption of 3rd party software components. [https://safedep.io](https://safedep.io) to get started with usage.
4+
5+
> This README is for Gateway developers. Refer to [https://safedep.io](https://safedep.io) for usage instructions for various environments and use-cases.
216
227
## TL;DR
238

@@ -54,7 +39,7 @@ Verify all the services are active
5439
docker-compose ps
5540
```
5641

57-
Use the gateway using a `demo-client`
42+
Use the gateway using a [demo-client](https://github.com/safedep/demo-client-java)
5843

5944
```bash
6045
cd demo-clients/java-gradle && ./gradlew assemble --refresh-dependencies
@@ -69,7 +54,7 @@ docker-compose logs pdp
6954

7055
The `gradle` build should fail with an error message indicating a dependency was blocked by the gateway.
7156

72-
```
57+
```bash
7358
> Could not resolve all files for configuration ':app:compileClasspath'.
7459
> Could not resolve org.apache.logging.log4j:log4j:2.16.0.
7560
Required by:
@@ -81,7 +66,7 @@ The `gradle` build should fail with an error message indicating a dependency was
8166

8267
> Refer to `policies/example.rego` for the policy that blocked this artefact
8368
84-
Edit `config/global.yml` and set `pdp.monitor_mode=true` to enable only monitoring and disable policy enforcement. Restart the containers for the changes to take effect.
69+
Edit `config/gateway.json` and set `pdp.monitor_mode=true` to enable only monitoring and disable policy enforcement. Restart the containers for the changes to take effect.
8570

8671
```bash
8772
docker-compose up --force-recreate --remove-orphans --build -d
@@ -109,114 +94,10 @@ If you are developing on any of the service and want to force re-create the cont
10994
docker-compose up --force-recreate --remove-orphans --build -d
11095
```
11196

112-
### Configuring Upstream and Routes
113-
114-
The configuration plane is currently half baked. It needs a tool and a single source of truth to generate configuration for Envoy and Gateway. For now, look at:
115-
116-
1. `config/global.yml`
117-
2. `config/envoy.yml`
118-
119-
> The route definitions in `envoy.yml` must match the path patterns in `global.yml`
120-
121-
### Configuring Environments
122-
123-
To use the gateway in a CI or developer local environment, package managers need to be configured to use the gateway URL and credentials as repository.
124-
125-
[PacMan](pacman/README.md) makes it easy to automatically configure an environment to use the gateway for downloading 3rd party dependencies.
126-
127-
### Authentication
128-
129-
There are two authentication points:
130-
131-
1. Ingress
132-
2. Egress
133-
134-
Ingress authentication is for incoming requests to the gateway and can be used to identify who is accessing the gateway.
135-
136-
Egress authentication is for upstream repositories, especially the ones that need authentication e.g. CodeArtifact, JFrog, Nexus etc.
137-
138-
- [Ingress Gateway Authentication](docs/Gateway-Authentication.md)
139-
140-
#### Ingress Authentication
141-
142-
##### Basic Authentication
143-
144-
Use `htpasswd` to add users:
145-
146-
```bash
147-
htpasswd -nbB user1 password1 >> ./config/gateway-auth-basic
148-
```
149-
150-
Enable authentication for upstream in `config/global.yml`
151-
152-
## Development
153-
154-
### PDP Development
97+
## Developer Documentation
15598

156-
Build and run the PDP using:
157-
158-
```bash
159-
cd services && make
160-
GLOBAL_CONFIG_PATH=../config/global.yml PDP_POLICY_PATH=../policies ./out/pdp-server
161-
```
162-
163-
PDP listens on `0.0.0.0:9000`. To use the host instance of PDP, edit `config/envoy.yml` and set the address of the `ExtAuthZ` plugin to your host network address.
164-
165-
### Policy Development
166-
167-
Policies are written in [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/) and evaluated with [Open Policy Agent](https://www.openpolicyagent.org/docs/latest/integration/#integrating-with-the-go-api)
168-
169-
To run policy test cases:
170-
171-
```bash
172-
cd policies && make test
173-
```
174-
175-
* Refer to `policies/example.rego` for policy example
176-
* Policies are load from `./policies` directory
177-
178-
### Tap Development
179-
180-
The *Tap Service* is integrated as a Envoy [ExtProc](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/ext_proc_filter) filter. This means, it has greater control over Envoy's request processing life-cycle and can make changes if required.
181-
182-
Currently, it is used for publishing events for data collection only but in future may be extended to support other use-cases. Tap service internally implements a handler chain to delegate an Envoy event to its internal handlers. Example:
183-
184-
```go
185-
tapService, err := tap.NewTapService(config, []tap.TapHandlerRegistration{
186-
tap.NewTapEventPublisherRegistration(),
187-
})
188-
```
189-
190-
To build and use from host:
191-
192-
```bash
193-
cd services && make
194-
GLOBAL_CONFIG_PATH=../config/global.yml ./out/tap-server
195-
```
196-
197-
> To use Tap service from host, edit `envoy.yml` and change address of `ext-proc-tap` cluster.
198-
199-
### Debug NATS Messaging
200-
201-
Start a docker container with `nats` client
202-
203-
```bash
204-
docker run --rm -it \
205-
--network supply-chain-security-gateway_default \
206-
-v `pwd`:/workspace \
207-
synadia/nats-box
208-
```
209-
210-
Subscribe to a subject and receive messages
211-
212-
```bash
213-
GODEBUG=x509ignoreCN=0 nats sub \
214-
--tlscert=/workspace/pki/tap/server.crt \
215-
--tlskey=/workspace/pki/tap/server.key \
216-
--tlsca=/workspace/pki/root.crt \
217-
--server=tls://nats-server:4222 \
218-
com.msg.event.upstream.request
219-
```
99+
* [Authentication](docs/Authentication.md)
100+
* [Service Development](docs/Development.md)
220101

221102
## Contribution
222103

bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ MYSQL_DCS_USER=root
4343
MYSQL_DCS_PASSWORD=$mysql_root_pass
4444
4545
KAFKA_PONGO_HOST=127.0.0.1
46+
OPENSEARCH_HOST=172.17.0.1
4647
_EOF
4748
fi

0 commit comments

Comments
 (0)