Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
44 changes: 44 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"plugins": ["@angular-eslint"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["tsconfig.json", "e2e/tsconfig.json"],
"createDefaultProgram": true
},
"extends": ["plugin:@angular-eslint/template/process-inline-templates", "prettier"],
"rules": {
"@angular-eslint/component-selector": "off",
"@angular-eslint/directive-selector": "off",
"prefer-arrow/prefer-arrow-functions": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/member-ordering": "off",
"jsdoc/newline-after-description": "off",
"@angular-eslint/no-output-native": "off",
"@angular-eslint/component-class-suffix": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/dot-notation": "off",
"@angular-eslint/no-input-rename": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/unified-signatures": "off",
"id-blacklist": "off",
"id-match": "off",
"no-underscore-dangle": "off"
}
},
{
"files": ["*.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"rules": {}
}
]
}
67 changes: 67 additions & 0 deletions .github/actions/secret-scanner/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Secret Scanner

description: Scans the code base to detect for the presence of secrets.

inputs:
github_token:
required: true
description: GitHub token for authentication, required for accessing the repository and posting comments.

gitleaks_license:
required: true
description: Gitleaks license key to use the licensed version.

gitleaks_regex_internal_url:
required: true
description: Regex to identify internal urls

gitleaks_regex_banned_ids:
required: true
description: Regex to identify banned IDs

runs:
using: "composite"
steps:
- name: Prepare Gitleaks config
shell: bash
run: |
echo "Executing step: Prepare Gitleaks config"
set -euo pipefail

# Validate that regex parameters are not empty or null
# Note: Missing secrets evaluate to empty strings in GitHub Actions
GITLEAKS_REGEX_INTERNAL_URL_VALUE="${{ inputs.gitleaks_regex_internal_url }}"
GITLEAKS_REGEX_BANNED_IDS_VALUE="${{ inputs.gitleaks_regex_banned_ids }}"

if [ -z "$GITLEAKS_REGEX_INTERNAL_URL_VALUE" ] || [ "$GITLEAKS_REGEX_INTERNAL_URL_VALUE" = "null" ]; then
echo "::error::gitleaks_regex_internal_url is required and cannot be empty or null. Please ensure the secret is defined and has a value."
exit 1
fi

if [ -z "$GITLEAKS_REGEX_BANNED_IDS_VALUE" ] || [ "$GITLEAKS_REGEX_BANNED_IDS_VALUE" = "null" ]; then
echo "::error::gitleaks_regex_banned_ids is required and cannot be empty or null. Please ensure the secret is defined and has a value."
exit 1
fi

export GITLEAKS_REGEX_INTERNAL_URL="$GITLEAKS_REGEX_INTERNAL_URL_VALUE"
export GITLEAKS_REGEX_BANNED_IDS="$GITLEAKS_REGEX_BANNED_IDS_VALUE"
CUSTOM_CONFIG_FILE="$RUNNER_TEMP/gitleaks-custom-rules.toml"
envsubst < "${{ github.action_path }}/gitleaks-custom-rules-template.toml" > "$CUSTOM_CONFIG_FILE"

# Set GITLEAKS_CONFIG env variable and make it available to subsequent steps
echo "GITLEAKS_CONFIG=$CUSTOM_CONFIG_FILE" >> "$GITHUB_ENV"
echo "------------ Scan will run with builtin + custom rules ------------"

- name: Gitleaks scanning
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
GITLEAKS_LICENSE: ${{ inputs.gitleaks_license }}
GITLEAKS_ENABLE_COMMENTS: "false" # suppress PR comments
GITLEAKS_ENABLE_SUMMARY: "false" # suppress Job Summary

- name: TruffleHog 🐽 scanning
uses: trufflesecurity/trufflehog@main
with:
extra_args: --results=verified

35 changes: 35 additions & 0 deletions .github/actions/secret-scanner/gitleaks-custom-rules-template.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
title = "Custom rules"

[extend]
useDefault = true

[[rules]]
id = "internal-urls"
description = "Identify internal urls"
regex = '''${GITLEAKS_REGEX_INTERNAL_URL}'''
tags = ["internal-urls"]

[[rules]]
id = "banned-ids"
description = "Identify banned IDs"
regex = '''${GITLEAKS_REGEX_BANNED_IDS}'''
tags = ["banned-ids"]

# ---------------------------------------------------------------------------
# Reviewed and accepted values. Each entry is matched against a finding's
# secret, so only these exact values are excluded - the rules above still
# apply everywhere else.
# - "vnd.<service>.query.local" HTTP media types, which are content-type
# identifiers rather than hostnames (only the trailing ".local" matches)
# - user-id UUIDs used by the test fixtures under projects/testing
# ---------------------------------------------------------------------------
[allowlist]
description = "Accepted values"
regexes = [
'''^vnd\.[A-Za-z0-9.-]+\.local$''',
'''^d7c91866-646a-462c-9203-46678e8cddef$''',
'''^48a948dc-7d96-45bd-baa5-5237432152d2$''',
'''^ad0920bd-521a-4f40-b942-f82d258ea3cc$''',
'''^0e61972a-0a26-4de1-a676-36119c535a60$'''
]

24 changes: 24 additions & 0 deletions .github/workflows/secret-scanning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Scanning
on:
pull_request:
branches:
- '**'
schedule:
- cron: '0 4 * * 4' # Every Thursday at 04:00
workflow_dispatch:

jobs:
scan:
name: Secrets Scanner
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/secret-scanner
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
gitleaks_license: ${{ secrets.GITLEAKS_LICENSE }}
gitleaks_regex_internal_url: ${{ secrets.HMCTS_CP_GITLEAKS_REGEX_INTERNAL_URL }}
gitleaks_regex_banned_ids: ${{ secrets.HMCTS_CP_GITLEAKS_REGEX_BANNED_IDS }}
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/build
/dist
/tmp
/release
/out-tsc

# dependencies
/node_modules
.npmrc

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
.scannerwork/
/typings

# System Files
.DS_Store
Thumbs.db
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 100,
"singleQuote": true,
"useTabs": false,
"tabWidth": 2,
"semi": true,
"bracketSpacing": true,
"trailingComma": "none"
}
46 changes: 46 additions & 0 deletions .scripts/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const path = require('path');
const fs = require('fs');
const buildDir = path.join(__dirname, '../dist');
const caretRangeRegex = /^\^0\.0\.0-PLACEHOLDER$/;

if (!process.env.npm_package_version) {
throw new Error(
'[Build] Failed to determine package version. ' +
'Did you forget to supply an `npm_package_version` environment variable?'
);
}

function updateCppPeerDependencies(packageJson, newVersion) {
if (!packageJson.peerDependencies) {
return;
}
for (const [depName, currentRange] of Object.entries(packageJson.peerDependencies)) {
if (currentRange.match(caretRangeRegex)) {
packageJson.peerDependencies[depName] = `^${newVersion}`;
console.log(
`[Build] Bumped ${depName} peer dependency: ${currentRange} to ${packageJson.peerDependencies[depName]}`
);
}
}
}

try {
const newVersion = process.env.npm_package_version.trim();
const directoryNames = fs.readdirSync(buildDir).filter((item) => {
const itemPath = path.join(buildDir, item);
return fs.statSync(itemPath).isDirectory();
});

directoryNames.forEach((packageName) => {
const pathToPackage = path.join(buildDir, packageName, 'package.json');
const packageJson = {
...require(pathToPackage),
version: newVersion
};
updateCppPeerDependencies(packageJson, newVersion);
fs.writeFileSync(pathToPackage, JSON.stringify(packageJson, null, 2));
console.log(`[Build] Bumped ${packageJson.name} to ${packageJson.version}.`);
});
} catch (e) {
console.log(`[Build] Versioning failed: ${e.toString()}`);
}
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# cpp-ui-core
# CppCore

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.1.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
Loading
Loading