19 Commits

Author SHA1 Message Date
minori a9c75410a2 deps: update @nhcarrigan/eslint-config to 5.2.0
Node.js CI / CI (pull_request) Successful in 27s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 2m9s
2026-02-04 08:17:12 -08:00
hikari a75e8a5e35 docs: update feedback section to use support forum
Node.js CI / CI (push) Successful in 17s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m27s
2026-01-26 12:37:00 -08:00
naomi 17f4eb57e3 feat: automated upload of .gitea/workflows/ci.yml
Node.js CI / CI (push) Successful in 17s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 56s
2025-12-22 19:42:08 +01:00
naomi 3c76aad2c0 feat: automated upload of .gitea/workflows/ci.yml
Node.js CI / CI (push) Has been cancelled
Security Scan and Upload / Security & DefectDojo Upload (push) Has been cancelled
2025-12-22 19:35:34 +01:00
naomi bd04a1fed8 feat: automated upload of .gitea/workflows/ci.yml
Node.js CI / Lint and Test (push) Has been cancelled
Security Scan and Upload / Security & DefectDojo Upload (push) Has been cancelled
2025-12-22 19:25:24 +01:00
naomi aff3a9a131 feat: automated upload of .npmrc
Security Scan and Upload / Security & DefectDojo Upload (push) Has been cancelled
Node.js CI / Lint and Test (push) Has been cancelled
2025-12-22 19:16:16 +01:00
naomi 4d20053e7c feat: automated upload of .gitea/workflows/security.yml
Node.js CI / Lint and Test (push) Successful in 18s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 58s
2025-12-18 03:08:11 +01:00
naomi af24d21b26 feat: automated upload of .gitea/workflows/security.yml
Node.js CI / Lint and Test (push) Successful in 18s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m4s
2025-12-17 23:26:10 +01:00
naomi 06669a5aab feat: automated upload of .gitea/workflows/security.yml
Node.js CI / Lint and Test (push) Successful in 18s
Security Scan / Security Audit (push) Failing after 8m6s
2025-12-12 03:37:56 +01:00
naomi 63331c2d8c feat: automated upload of .gitea/workflows/security.yml
Node.js CI / Lint and Test (push) Successful in 17s
Security Scan / Trivy Security Scan (push) Failing after 4m48s
2025-12-11 20:12:03 +01:00
naomi 936f588f7e release: v1.1.1
Node.js CI / Lint and Test (push) Successful in 31s
2025-10-07 17:45:02 -07:00
naomi 52190a5112 chore(tools): lint and build before publishing 2025-10-07 17:44:42 -07:00
naomi f0481af558 release: v1.1.0-hotfix
Node.js CI / Lint and Test (push) Successful in 31s
2025-10-07 16:41:10 -07:00
naomi 6f4f06d143 chore: remove sonar workflow
Node.js CI / Lint and Test (push) Successful in 28s
2025-10-07 16:11:56 -07:00
naomi c997e83aa5 release: v1.1.0
Code Analysis / SonarQube (push) Failing after 18s
Node.js CI / Lint and Test (push) Successful in 35s
2025-10-07 16:09:40 -07:00
naomi f2f5d9b1b4 feat: add method for sending metrics 2025-10-07 16:09:20 -07:00
naomi b65f3a4d6d chore: add sonar workflow
Node.js CI / Lint and Test (push) Successful in 45s
Code Analysis / SonarQube (push) Successful in 1m1s
2025-02-26 13:30:09 -08:00
naomi 4f7f2d87e5 release: v1.0.0
Node.js CI / Lint and Test (push) Successful in 29s
2025-02-10 20:58:34 -08:00
naomi 9d9fa40bcb feat: initial prototype (#1)
Node.js CI / Lint and Test (push) Has been cancelled
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [x] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [x] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [x] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [x] I have pinned the dependencies to a specific patch version.

### Style

- [x] I have run the linter and resolved any errors.
- [x] My pull request uses an appropriate title, matching the conventional commit standards.
- [x] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

Major - My pull request introduces a breaking change.

Reviewed-on: #1
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2025-02-10 20:58:23 -08:00
13 changed files with 4436 additions and 14 deletions
+47
View File
@@ -0,0 +1,47 @@
name: Node.js CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- name: Checkout Source Files
uses: actions/checkout@v4
- name: Use Node.js v24
uses: actions/setup-node@v4
with:
node-version: 24
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 10
- name: Ensure Dependencies are Pinned
uses: naomi-lgbt/dependency-pin-check@main
with:
language: javascript
dev-dependencies: true
peer-dependencies: true
optional-dependencies: true
- name: Install Dependencies
run: pnpm install
- name: Lint Source Files
run: pnpm run lint
- name: Verify Build
run: pnpm run build
- name: Run Tests
run: pnpm run test
+177
View File
@@ -0,0 +1,177 @@
name: Security Scan and Upload
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
security-audit:
name: Security & DefectDojo Upload
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v4
# --- AUTO-SETUP PROJECT ---
- name: Ensure DefectDojo Product Exists
env:
DD_URL: ${{ secrets.DD_URL }}
DD_TOKEN: ${{ secrets.DD_TOKEN }}
PRODUCT_NAME: ${{ github.repository }}
PRODUCT_TYPE_ID: 1
run: |
sudo apt-get install jq -y > /dev/null
echo "Checking connection to $DD_URL..."
# Check if product exists - capture HTTP code to debug connection issues
RESPONSE=$(curl --write-out "%{http_code}" --silent --output /tmp/response.json \
-H "Authorization: Token $DD_TOKEN" \
"$DD_URL/api/v2/products/?name=$PRODUCT_NAME")
# If response is not 200, print error
if [ "$RESPONSE" != "200" ]; then
echo "::error::Failed to query DefectDojo. HTTP Code: $RESPONSE"
cat /tmp/response.json
exit 1
fi
COUNT=$(cat /tmp/response.json | jq -r '.count')
if [ "$COUNT" = "0" ]; then
echo "Creating product '$PRODUCT_NAME'..."
curl -s -X POST "$DD_URL/api/v2/products/" \
-H "Authorization: Token $DD_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "'"$PRODUCT_NAME"'", "description": "Auto-created by Gitea Actions", "prod_type": '$PRODUCT_TYPE_ID' }'
else
echo "Product '$PRODUCT_NAME' already exists."
fi
# --- 1. TRIVY (Dependencies & Misconfig) ---
- name: Install Trivy
run: |
sudo apt-get install wget apt-transport-https gnupg lsb-release -y
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update && sudo apt-get install trivy -y
- name: Run Trivy (FS Scan)
run: |
trivy fs . --scanners vuln,misconfig --format json --output trivy-results.json --exit-code 0
- name: Upload Trivy to DefectDojo
env:
DD_URL: ${{ secrets.DD_URL }}
DD_TOKEN: ${{ secrets.DD_TOKEN }}
run: |
echo "Uploading Trivy results..."
# Generate today's date in YYYY-MM-DD format
TODAY=$(date +%Y-%m-%d)
HTTP_CODE=$(curl --write-out "%{http_code}" --output response.txt --silent -X POST "$DD_URL/api/v2/import-scan/" \
-H "Authorization: Token $DD_TOKEN" \
-F "active=true" \
-F "verified=true" \
-F "scan_type=Trivy Scan" \
-F "engagement_name=CI/CD Pipeline" \
-F "product_name=${{ github.repository }}" \
-F "scan_date=$TODAY" \
-F "auto_create_context=true" \
-F "file=@trivy-results.json")
if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "201" ]]; then
echo "::error::Upload Failed with HTTP $HTTP_CODE"
echo "--- SERVER RESPONSE ---"
cat response.txt
echo "-----------------------"
exit 1
else
echo "Upload Success!"
fi
# --- 2. GITLEAKS (Secrets) ---
- name: Install Gitleaks
run: |
wget -qO gitleaks.tar.gz https://github.com/gitleaks/gitleaks/releases/download/v8.18.0/gitleaks_8.18.0_linux_x64.tar.gz
tar -xzf gitleaks.tar.gz
sudo mv gitleaks /usr/local/bin/ && chmod +x /usr/local/bin/gitleaks
- name: Run Gitleaks
run: gitleaks detect --source . -v --report-path gitleaks-results.json --report-format json --no-git || true
- name: Upload Gitleaks to DefectDojo
env:
DD_URL: ${{ secrets.DD_URL }}
DD_TOKEN: ${{ secrets.DD_TOKEN }}
run: |
echo "Uploading Gitleaks results..."
TODAY=$(date +%Y-%m-%d)
HTTP_CODE=$(curl --write-out "%{http_code}" --output response.txt --silent -X POST "$DD_URL/api/v2/import-scan/" \
-H "Authorization: Token $DD_TOKEN" \
-F "active=true" \
-F "verified=true" \
-F "scan_type=Gitleaks Scan" \
-F "engagement_name=CI/CD Pipeline" \
-F "product_name=${{ github.repository }}" \
-F "scan_date=$TODAY" \
-F "auto_create_context=true" \
-F "file=@gitleaks-results.json")
if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "201" ]]; then
echo "::error::Upload Failed with HTTP $HTTP_CODE"
echo "--- SERVER RESPONSE ---"
cat response.txt
echo "-----------------------"
exit 1
else
echo "Upload Success!"
fi
# --- 3. SEMGREP (SAST) ---
- name: Install Semgrep (via pipx)
run: |
sudo apt-get install pipx -y
pipx install semgrep
# Add pipx binary path to GITHUB_PATH so next steps can see 'semgrep'
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run Semgrep
run: semgrep scan --config=p/security-audit --config=p/owasp-top-ten --json --output semgrep-results.json . || true
- name: Upload Semgrep to DefectDojo
env:
DD_URL: ${{ secrets.DD_URL }}
DD_TOKEN: ${{ secrets.DD_TOKEN }}
run: |
echo "Uploading Semgrep results..."
TODAY=$(date +%Y-%m-%d)
HTTP_CODE=$(curl --write-out "%{http_code}" --output response.txt --silent -X POST "$DD_URL/api/v2/import-scan/" \
-H "Authorization: Token $DD_TOKEN" \
-F "active=true" \
-F "verified=true" \
-F "scan_type=Semgrep JSON Report" \
-F "engagement_name=CI/CD Pipeline" \
-F "product_name=${{ github.repository }}" \
-F "scan_date=$TODAY" \
-F "auto_create_context=true" \
-F "file=@semgrep-results.json")
if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "201" ]]; then
echo "::error::Upload Failed with HTTP $HTTP_CODE"
echo "--- SERVER RESPONSE ---"
cat response.txt
echo "-----------------------"
exit 1
else
echo "Upload Success!"
fi
+6
View File
@@ -0,0 +1,6 @@
node_modules
prod
coverage
# Ignore packed files so that npm pack can be run locally
*.tgz
+9
View File
@@ -0,0 +1,9 @@
/.gitea/
/.vscode/
eslint.config.js
.gitattributes
.gitignore
/src/
# Ignore packed files so that npm pack can be run locally
*.tgz
+25
View File
@@ -0,0 +1,25 @@
# Package Manager Configuration
# Force pnpm usage - breaks npm/yarn intentionally
node-linker=pnpm
# Security: Disable all lifecycle scripts
ignore-scripts=true
enable-pre-post-scripts=false
# Security: Require packages to be 10+ days old before installation
minimum-release-age=14400
# Security: Verify package integrity hashes
verify-store-integrity=true
# Security: Enforce strict trust policies
trust-policy=strict
# Security: Strict peer dependency resolution
strict-peer-dependencies=true
# Performance: Use symlinks for node_modules
symlink=true
# Lockfile: Ensure lockfile is not modified during install
frozen-lockfile=false
+6
View File
@@ -0,0 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["typescript"]
}
+4 -14
View File
@@ -1,24 +1,14 @@
# New Repository Template
# Logger
This template contains all of our basic files for a new GitHub repository. There is also a handy workflow that will create an issue on a new repository made from this template, with a checklist for the steps we usually take in setting up a new repository.
If you're starting a Node.JS project with TypeScript, we have a [specific template](https://github.com/naomi-lgbt/nodejs-typescript-template) for that purpose.
## Readme
Delete all of the above text (including this line), and uncomment the below text to use our standard readme template.
<!-- # Project Name
Project Description
This is a custom logging utility which pipes errors and log messages to our alerting system.
## Live Version
This page is currently deployed. [View the live website.]
This page is currently deployed. [View the live website.](https://www.npmjs.com/package/@nhcarrigan/logger)
## Feedback and Bugs
If you have feedback or a bug report, please feel free to open a GitHub issue!
If you have feedback or a bug report, please [log a ticket on our forum](https://support.nhcarrigan.com).
## Contributing
+5
View File
@@ -0,0 +1,5 @@
import NaomisConfig from "@nhcarrigan/eslint-config";
export default [
...NaomisConfig
]
+31
View File
@@ -0,0 +1,31 @@
{
"name": "@nhcarrigan/logger",
"version": "1.1.1",
"description": "Our custom logging package, which pipes logs to our alerts server.",
"type": "module",
"main": "prod/index.js",
"scripts": {
"prepublish": "pnpm lint && pnpm build",
"lint": "eslint src --max-warnings 0",
"build": "rm -rf prod && tsc",
"test": "echo \"Error: no test specified\" && exit 0"
},
"repository": {
"type": "git",
"url": "https://git.nhcarrigan.com/nhcarrigan/logger.git"
},
"keywords": [],
"author": "",
"license": "See license in LICENSE.md",
"bugs": {
"url": "https://git.nhcarrigan.com/nhcarrigan/logger/issues"
},
"homepage": "https://git.nhcarrigan.com/nhcarrigan/logger",
"devDependencies": {
"@nhcarrigan/eslint-config": "5.2.0",
"@nhcarrigan/typescript-config": "4.0.0",
"@types/node": "22.13.1",
"eslint": "9.20.0",
"typescript": "5.7.3"
}
}
+4000
View File
File diff suppressed because it is too large Load Diff
+104
View File
@@ -0,0 +1,104 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import type { Level } from "./types/level.js";
/**
* This is a wrapper around our custom alert monitoring server. This class
* allows you to pipe errors and log messages to our server.
*/
export class Logger {
private readonly url: string;
/**
* Instantiates the class.
* @param application -- The name of the application (this will appear in logs).
* @param token -- Your API token for the monitoring service.
* @param url -- (Optional) The URL for your own alerting instance.
*/
public constructor(
private readonly application: string,
private readonly token: string,
url?: string,
) {
this.url = url ?? "https://alerts.nhcarrigan.com";
}
/**
* Sends a log message to the alerting service.
* @param level -- The level of the log message.
* @param message -- The message to send.
*/
public async log(level: Level, message: string): Promise<void> {
await fetch(`${this.url}/log`, {
body: JSON.stringify({
application: this.application,
level: level,
message: message,
}),
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
"Authorization": this.token,
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
"Content-Type": "application/json",
},
method: "POST",
});
}
/**
* Sends an error to the alerting service.
* @param context -- A brief description of where the error occurred (E.G. Function name).
* @param error -- The Node.js error object.
*/
public async error(context: string, error: Error): Promise<void> {
await fetch(`${this.url}/error`, {
body: JSON.stringify({
application: this.application,
context: context,
message: error.message,
stack: error.stack ?? "No stack trace available.",
}),
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
"Authorization": this.token,
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
"Content-Type": "application/json",
},
method: "POST",
});
}
/**
* Sends a counter metric to the alerting service.
* The alerting service is configured to handle aggregation, so you can send
* summative counts or individual increments. (e.g. Send a count of all users, or send a count of 1 every time a user joins).
* @param name -- The name of the metric to track.
* @param value -- The value of the metric to insert.
* @param metadata -- Any metadata to attach to the metric.
*/
public async metric(
name: string,
value: number,
metadata: Record<string, string | number | boolean>,
): Promise<void> {
await fetch(`${this.url}/metric`, {
body: JSON.stringify({
application: this.application,
metadata: metadata,
name: name,
value: value,
}),
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
"Authorization": this.token,
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
"Content-Type": "application/json",
},
method: "POST",
});
}
}
+12
View File
@@ -0,0 +1,12 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
/**
* Defines the levels we allow for logging. This is honestly
* entirely arbitrary, but ensures some level of consistency across
* our production applications.
*/
export type Level = "debug" | "info" | "warn";
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "@nhcarrigan/typescript-config",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./prod",
"sourceMap": true,
"declaration": true
},
"exclude": ["test/**/*.ts", "vitest.config.ts"]
}