Skip to content

Commit

Permalink
npm run format-all
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Jan 17, 2023
1 parent d49c910 commit ba937e2
Show file tree
Hide file tree
Showing 148 changed files with 2,865 additions and 2,263 deletions.
29 changes: 16 additions & 13 deletions .pre-commit-README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# Pre-Commit-Hook
The defined pre-commit-hook prevents committing passwords to the repository. In case a password is detected
git commit fails.

The defined pre-commit-hook prevents committing passwords to the repository. In
case a password is detected git commit fails.

## Install pre-commit
1. Install pre-commit-hook tool
`$ pip install pre-commit`
2. Install detect-secrets
`$ pip install detect-secrets`


1. Install pre-commit-hook tool `$ pip install pre-commit`
2. Install detect-secrets `$ pip install detect-secrets`

## Enable secret-scanning pre-commit hook
1. Update pre-commit-hook
`$ pre-commit autoupdate`
2. Enable defined pre-commit-hook
`$ pre-commit install`

1. Update pre-commit-hook `$ pre-commit autoupdate`
2. Enable defined pre-commit-hook `$ pre-commit install`

## On repository initialization of pre-commit hook with detect-secrets

If no `.secrets.baseline` is present, simply generate it:

1. `$ detect-secrets scan --disable-plugin KeywordDetector --disable-plugin AWSKeyDetector > .secrets.baseline`
2. Use Notepad++ or IntelliJ-Editor to convert `.secrets.baseline` to UTF-8

## Add false-positives or force adding secrets

1. `$ detect-secrets scan --baseline .secrets.baseline`
2. If secrets are identified, add them to .secrets.baseline manually
For more details see: https://github.com/Yelp/detect-secrets#adding-secrets-to-baseline
2. If secrets are identified, add them to .secrets.baseline manually For more
details see:
https://github.com/Yelp/detect-secrets#adding-secrets-to-baseline
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: package.lock.json
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: package.lock.json
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ in the detailed section referring to by linking pull requests or issues.
- Configuration via `EDC_UI_` environment variables in both local dev and docker container.
- See `app-config-properties.ts` for available properties.
- Configuration via single environment variable `EDC_UI_CONFIG_JSON` possible.
- Added prettier as code formatter.
- Formatted all non-generated code with prettier.

#### Removed

Expand Down
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
# EDC UI

EDC UI by sovity for our extended EDC Connector.

## Configuration
This Angular codebase uses ENV vars in both local dev and production to configure the application.

In general, all ENV vars `EDC_UI_*` will be written to a `assets/app-config.json`, either before starting the angular build server or before starting the nginx to serve static files.
This Angular codebase uses ENV vars in both local dev and production to
configure the application.

In general, all ENV vars `EDC_UI_*` will be written to a
`assets/app-config.json`, either before starting the angular build server or
before starting the nginx to serve static files.

All available configuration properties are documented in `src/modules/app/config/app-config-properties.ts`
All available configuration properties are documented in
`src/modules/app/config/app-config-properties.ts`

### Pass a JSON in an ENV Var
The ENV var `EDC_UI_CONFIG_JSON` can be used to pass a JSON that can contain all properties that would otherwise need to be specified individually. Individually provided ENV vars take precedence, however.

The ENV var `EDC_UI_CONFIG_JSON` can be used to pass a JSON that can contain all
properties that would otherwise need to be specified individually. Individually
provided ENV vars take precedence, however.

## Run dev mode

```shell
# Fake backend
(cd fake-backend && npm i && npm run start)
(cd fake-backend && npm i && npm run start)

# Run Angular Application
npm i
Expand All @@ -26,27 +34,30 @@ npm run start
### Configuring Dev Mode

For dev mode ENV vars are read from:

- Current Environment Variables (highest precedence)
- `.env` file (not committed, in .gitignore)
- `.env.local-dev` file (defaults for working with fake backend).

```properties
# Example:
# Example:
# Create a .env file to easily switch active feature sets
EDC_UI_ACTIVE_FEATURE_SET=mds
```

## Build docker image

```shell
# Build docker image
docker build -f "docker/Dockerfile" -t "edc-ui:latest" .

# Docker image will serve at :80
# Docker image will serve at :80
```

### Configuring docker image
At startup all ENV vars starting with `EDC_UI_` will be collected into a `assets/app-config.json` and served.

At startup all ENV vars starting with `EDC_UI_` will be collected into a
`assets/app-config.json` and served.

## Codegen for EDC REST API

Expand All @@ -55,7 +66,8 @@ At startup all ENV vars starting with `EDC_UI_` will be collected into a `assets
```shell
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/openapi/openapi.yaml -g typescript-angular -o /local/src/modules/edc-dmgmt-client/
```
This re-generates the service and model classes.

> Please note that some client classes were edited manually after generation. When regenerating the classes for the API update be careful especially not to overwrite service `constructor` methods using the generator!
This re-generates the service and model classes.

> Please note that some client classes were edited manually after generation.
> When regenerating the classes for the API update be careful especially not to
> overwrite service `constructor` methods using the generator!
32 changes: 20 additions & 12 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
## Security

sovity GmbH takes the security of its software products and services seriously, which includes all source code repositories managed through our GitHub organization: [sovity](https://github.com/sovity).
sovity GmbH takes the security of its software products and services seriously,
which includes all source code repositories managed through our GitHub
organization: [sovity](https://github.com/sovity).

If you believe you have found a security vulnerability in any of sovity's owned repositories, please report it to us as described below.
If you believe you have found a security vulnerability in any of sovity's owned
repositories, please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Instead, please report them via mail: [security@sovity.de](mailto:security@sovity.de)
Instead, please report them via mail:
[security@sovity.de](mailto:security@sovity.de)

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
You should receive a response within 24 hours. If for some reason you do not,
please follow up via email to ensure we received your original message.

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
Please include the requested information listed below (as much as you can
provide) to help us better understand the nature and scope of the possible
issue:

* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting,
etc.)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

Expand Down
22 changes: 6 additions & 16 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
},
"configurations": {
Expand Down Expand Up @@ -69,7 +64,7 @@
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
},
}
},
"defaultConfiguration": "production"
},
Expand All @@ -81,7 +76,7 @@
},
"development": {
"browserTarget": "edc-demo-client:build:development"
},
}
},
"options": {
"browserTarget": "project-name:build"
Expand All @@ -102,13 +97,8 @@
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
}
}
Expand Down
29 changes: 16 additions & 13 deletions config-generator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {writeFileSync, existsSync, readFileSync} = require("fs");
const dotenv = require('dotenv')
const {writeFileSync, existsSync, readFileSync} = require('fs');
const dotenv = require('dotenv');

// Generate app-config.json from ENV Vars
// Priority: ENV VAR > .env > .env.local-dev
Expand All @@ -14,10 +14,10 @@ const dotenv = require('dotenv')
* @return vars (Record<string, string>)
*/
const readEnvFileSync = (path) => {
if(existsSync(path)) {
if (existsSync(path)) {
return dotenv.parse(readFileSync(path));
}
return {}
return {};
};

/**
Expand All @@ -27,24 +27,27 @@ const readEnvFileSync = (path) => {
* @param fn filter fn (applied to property name)
* @return subset of obj
*/
const objFilterKeys = (obj, fn) => Object.fromEntries(Object.entries(obj).filter(([k, _]) => fn(k)));
const objFilterKeys = (obj, fn) =>
Object.fromEntries(Object.entries(obj).filter(([k, _]) => fn(k)));

// Read ENV Vars from .env files as well
const allProps = {
...readEnvFileSync(".env.local-dev"),
...readEnvFileSync(".env"),
...process.env
}
...readEnvFileSync('.env.local-dev'),
...readEnvFileSync('.env'),
...process.env,
};

// Collect ENV Vars with prefix EDC_UI_
const prefix = "EDC_UI_";
const filteredProps = objFilterKeys(allProps, k => k.startsWith(prefix));
const prefix = 'EDC_UI_';
const filteredProps = objFilterKeys(allProps, (k) => k.startsWith(prefix));
if (!Object.keys(filteredProps).length) {
console.warn(`No ${prefix} configuration properties are set in ENV, application might not be configured properly.`)
console.warn(
`No ${prefix} configuration properties are set in ENV, application might not be configured properly.`,
);
}

// Write app-config.json
const output = './src/assets/config/app-config.json'
const output = './src/assets/config/app-config.json';
const json = JSON.stringify(filteredProps);
writeFileSync(output, json);

Expand Down
32 changes: 8 additions & 24 deletions fake-backend/json/contractDefinitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:bitcoin3"
]
"operandRight": ["urn:artifact:bitcoin3"]
}
],
"id": "offering"
Expand All @@ -20,9 +18,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:bitcoin"
]
"operandRight": ["urn:artifact:bitcoin"]
}
],
"id": "bitcoin-3-contract"
Expand All @@ -34,9 +30,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:emissions"
]
"operandRight": ["urn:artifact:emissions"]
}
],
"id": "emissions-end-of-the-year-offering"
Expand All @@ -48,9 +42,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:ethereum2"
]
"operandRight": ["urn:artifact:ethereum2"]
}
],
"id": "ETH-Value"
Expand All @@ -62,9 +54,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:electrocharging"
]
"operandRight": ["urn:artifact:electrocharging"]
}
],
"id": "charging-contract-time-restricted"
Expand All @@ -76,9 +66,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:sharedmobilityescooter"
]
"operandRight": ["urn:artifact:sharedmobilityescooter"]
}
],
"id": "escooterswiss-contract-definition"
Expand All @@ -90,9 +78,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:methane-emissions-timeseries"
]
"operandRight": ["urn:artifact:methane-emissions-timeseries"]
}
],
"id": "Methane-contract-definition"
Expand All @@ -104,9 +90,7 @@
{
"operandLeft": "asset:prop:id",
"operator": "in",
"operandRight": [
"urn:artifact:chargingstationswalkthrough"
]
"operandRight": ["urn:artifact:chargingstationswalkthrough"]
}
],
"id": "Charging Station - Walkthrough"
Expand Down
Loading

0 comments on commit ba937e2

Please sign in to comment.