5 Commits

Author SHA1 Message Date
naomi ef00f107e9 fix: ephemeral response 2025-03-07 11:25:06 -08:00
naomi 790be688ea fix: scopes 2025-03-07 11:24:31 -08:00
naomi 867594efbe fix: handle slack empty body 2025-03-07 11:20:23 -08:00
naomi 05634b9a4c fix: install url 2025-03-07 11:18:22 -08:00
naomi 970a31895d feat: initial prototype 2025-03-07 11:13:40 -08:00
13 changed files with 236 additions and 351 deletions
-47
View File
@@ -1,47 +0,0 @@
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
@@ -1,177 +0,0 @@
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
-1
View File
@@ -1,2 +1 @@
node_modules node_modules
prod
-25
View File
@@ -1,25 +0,0 @@
# 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
+1 -1
View File
@@ -18,7 +18,7 @@ This page is currently deployed. [View the live website.]
## Feedback and Bugs ## Feedback and Bugs
If you have feedback or a bug report, please [log a ticket on our forum](https://support.nhcarrigan.com). If you have feedback or a bug report, please feel free to open a GitHub issue!
## Contributing ## Contributing
+2 -2
View File
@@ -9,7 +9,7 @@
"dev": "tsx watch src/index.ts", "dev": "tsx watch src/index.ts",
"lint": "eslint src --max-warnings 0", "lint": "eslint src --max-warnings 0",
"start": "op run --env-file=prod.env --no-masking -- node prod/index.js", "start": "op run --env-file=prod.env --no-masking -- node prod/index.js",
"test": "echo \"Error: no test specified\" && exit 0" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"keywords": [], "keywords": [],
"author": "Naomi Carrigan", "author": "Naomi Carrigan",
@@ -27,7 +27,7 @@
"@nhcarrigan/logger": "1.0.0", "@nhcarrigan/logger": "1.0.0",
"@slack/bolt": "4.2.1", "@slack/bolt": "4.2.1",
"@slack/oauth": "3.0.2", "@slack/oauth": "3.0.2",
"discord.js": "14.25.1", "discord.js": "14.18.0",
"fastify": "5.2.1", "fastify": "5.2.1",
"no-profanity": "1.5.1", "no-profanity": "1.5.1",
"node-schedule": "2.1.1" "node-schedule": "2.1.1"
+43 -56
View File
@@ -21,8 +21,8 @@ importers:
specifier: 3.0.2 specifier: 3.0.2
version: 3.0.2 version: 3.0.2
discord.js: discord.js:
specifier: 14.25.1 specifier: 14.18.0
version: 14.25.1 version: 14.18.0
fastify: fastify:
specifier: 5.2.1 specifier: 5.2.1
version: 5.2.1 version: 5.2.1
@@ -77,8 +77,8 @@ packages:
resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
'@discordjs/builders@1.13.1': '@discordjs/builders@1.10.1':
resolution: {integrity: sha512-cOU0UDHc3lp/5nKByDxkmRiNZBpdp0kx55aarbiAfakfKJHlxv/yFW1zmIqCAmwH5CRlrH9iMFKJMpvW4DPB+w==} resolution: {integrity: sha512-OWo1fY4ztL1/M/DUyRPShB4d/EzVfuUvPTRRHRIt/YxBrUYSz0a+JicD5F5zHFoNs2oTuWavxCOVFV1UljHTng==}
engines: {node: '>=16.11.0'} engines: {node: '>=16.11.0'}
'@discordjs/collection@1.5.3': '@discordjs/collection@1.5.3':
@@ -89,20 +89,20 @@ packages:
resolution: {integrity: sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==} resolution: {integrity: sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==}
engines: {node: '>=18'} engines: {node: '>=18'}
'@discordjs/formatters@0.6.2': '@discordjs/formatters@0.6.0':
resolution: {integrity: sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==} resolution: {integrity: sha512-YIruKw4UILt/ivO4uISmrGq2GdMY6EkoTtD0oS0GvkJFRZbTSdPhzYiUILbJ/QslsvC9H9nTgGgnarnIl4jMfw==}
engines: {node: '>=16.11.0'} engines: {node: '>=16.11.0'}
'@discordjs/rest@2.6.0': '@discordjs/rest@2.4.3':
resolution: {integrity: sha512-RDYrhmpB7mTvmCKcpj+pc5k7POKszS4E2O9TYc+U+Y4iaCP+r910QdO43qmpOja8LRr1RJ0b3U+CqVsnPqzf4w==} resolution: {integrity: sha512-+SO4RKvWsM+y8uFHgYQrcTl/3+cY02uQOH7/7bKbVZsTfrfpoE62o5p+mmV+s7FVhTX82/kQUGGbu4YlV60RtA==}
engines: {node: '>=18'} engines: {node: '>=18'}
'@discordjs/util@1.2.0': '@discordjs/util@1.1.1':
resolution: {integrity: sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==} resolution: {integrity: sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==}
engines: {node: '>=18'} engines: {node: '>=18'}
'@discordjs/ws@1.2.3': '@discordjs/ws@1.2.1':
resolution: {integrity: sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==} resolution: {integrity: sha512-PBvenhZG56a6tMWF/f4P6f4GxZKJTBG95n7aiGSPTnodmz4N5g60t79rSIAq7ywMbv8A4jFtexMruH+oe51aQQ==}
engines: {node: '>=16.11.0'} engines: {node: '>=16.11.0'}
'@es-joy/jsdoccomment@0.49.0': '@es-joy/jsdoccomment@0.49.0':
@@ -426,61 +426,51 @@ packages:
resolution: {integrity: sha512-88I+D3TeKItrw+Y/2ud4Tw0+3CxQ2kLgu3QvrogZ0OfkmX/DEppehus7L3TS2Q4lpB+hYyxhkQiYPJ6Mf5/dPg==} resolution: {integrity: sha512-88I+D3TeKItrw+Y/2ud4Tw0+3CxQ2kLgu3QvrogZ0OfkmX/DEppehus7L3TS2Q4lpB+hYyxhkQiYPJ6Mf5/dPg==}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm-musleabihf@4.34.9': '@rollup/rollup-linux-arm-musleabihf@4.34.9':
resolution: {integrity: sha512-3qyfWljSFHi9zH0KgtEPG4cBXHDFhwD8kwg6xLfHQ0IWuH9crp005GfoUUh/6w9/FWGBwEHg3lxK1iHRN1MFlA==} resolution: {integrity: sha512-3qyfWljSFHi9zH0KgtEPG4cBXHDFhwD8kwg6xLfHQ0IWuH9crp005GfoUUh/6w9/FWGBwEHg3lxK1iHRN1MFlA==}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
libc: [musl]
'@rollup/rollup-linux-arm64-gnu@4.34.9': '@rollup/rollup-linux-arm64-gnu@4.34.9':
resolution: {integrity: sha512-6TZjPHjKZUQKmVKMUowF3ewHxctrRR09eYyvT5eFv8w/fXarEra83A2mHTVJLA5xU91aCNOUnM+DWFMSbQ0Nxw==} resolution: {integrity: sha512-6TZjPHjKZUQKmVKMUowF3ewHxctrRR09eYyvT5eFv8w/fXarEra83A2mHTVJLA5xU91aCNOUnM+DWFMSbQ0Nxw==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.34.9': '@rollup/rollup-linux-arm64-musl@4.34.9':
resolution: {integrity: sha512-LD2fytxZJZ6xzOKnMbIpgzFOuIKlxVOpiMAXawsAZ2mHBPEYOnLRK5TTEsID6z4eM23DuO88X0Tq1mErHMVq0A==} resolution: {integrity: sha512-LD2fytxZJZ6xzOKnMbIpgzFOuIKlxVOpiMAXawsAZ2mHBPEYOnLRK5TTEsID6z4eM23DuO88X0Tq1mErHMVq0A==}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
libc: [musl]
'@rollup/rollup-linux-loongarch64-gnu@4.34.9': '@rollup/rollup-linux-loongarch64-gnu@4.34.9':
resolution: {integrity: sha512-dRAgTfDsn0TE0HI6cmo13hemKpVHOEyeciGtvlBTkpx/F65kTvShtY/EVyZEIfxFkV5JJTuQ9tP5HGBS0hfxIg==} resolution: {integrity: sha512-dRAgTfDsn0TE0HI6cmo13hemKpVHOEyeciGtvlBTkpx/F65kTvShtY/EVyZEIfxFkV5JJTuQ9tP5HGBS0hfxIg==}
cpu: [loong64] cpu: [loong64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-powerpc64le-gnu@4.34.9': '@rollup/rollup-linux-powerpc64le-gnu@4.34.9':
resolution: {integrity: sha512-PHcNOAEhkoMSQtMf+rJofwisZqaU8iQ8EaSps58f5HYll9EAY5BSErCZ8qBDMVbq88h4UxaNPlbrKqfWP8RfJA==} resolution: {integrity: sha512-PHcNOAEhkoMSQtMf+rJofwisZqaU8iQ8EaSps58f5HYll9EAY5BSErCZ8qBDMVbq88h4UxaNPlbrKqfWP8RfJA==}
cpu: [ppc64] cpu: [ppc64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-riscv64-gnu@4.34.9': '@rollup/rollup-linux-riscv64-gnu@4.34.9':
resolution: {integrity: sha512-Z2i0Uy5G96KBYKjeQFKbbsB54xFOL5/y1P5wNBsbXB8yE+At3oh0DVMjQVzCJRJSfReiB2tX8T6HUFZ2k8iaKg==} resolution: {integrity: sha512-Z2i0Uy5G96KBYKjeQFKbbsB54xFOL5/y1P5wNBsbXB8yE+At3oh0DVMjQVzCJRJSfReiB2tX8T6HUFZ2k8iaKg==}
cpu: [riscv64] cpu: [riscv64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-s390x-gnu@4.34.9': '@rollup/rollup-linux-s390x-gnu@4.34.9':
resolution: {integrity: sha512-U+5SwTMoeYXoDzJX5dhDTxRltSrIax8KWwfaaYcynuJw8mT33W7oOgz0a+AaXtGuvhzTr2tVKh5UO8GVANTxyQ==} resolution: {integrity: sha512-U+5SwTMoeYXoDzJX5dhDTxRltSrIax8KWwfaaYcynuJw8mT33W7oOgz0a+AaXtGuvhzTr2tVKh5UO8GVANTxyQ==}
cpu: [s390x] cpu: [s390x]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-gnu@4.34.9': '@rollup/rollup-linux-x64-gnu@4.34.9':
resolution: {integrity: sha512-FwBHNSOjUTQLP4MG7y6rR6qbGw4MFeQnIBrMe161QGaQoBQLqSUEKlHIiVgF3g/mb3lxlxzJOpIBhaP+C+KP2A==} resolution: {integrity: sha512-FwBHNSOjUTQLP4MG7y6rR6qbGw4MFeQnIBrMe161QGaQoBQLqSUEKlHIiVgF3g/mb3lxlxzJOpIBhaP+C+KP2A==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.34.9': '@rollup/rollup-linux-x64-musl@4.34.9':
resolution: {integrity: sha512-cYRpV4650z2I3/s6+5/LONkjIz8MBeqrk+vPXV10ORBnshpn8S32bPqQ2Utv39jCiDcO2eJTuSlPXpnvmaIgRA==} resolution: {integrity: sha512-cYRpV4650z2I3/s6+5/LONkjIz8MBeqrk+vPXV10ORBnshpn8S32bPqQ2Utv39jCiDcO2eJTuSlPXpnvmaIgRA==}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
libc: [musl]
'@rollup/rollup-win32-arm64-msvc@4.34.9': '@rollup/rollup-win32-arm64-msvc@4.34.9':
resolution: {integrity: sha512-z4mQK9dAN6byRA/vsSgQiPeuO63wdiDxZ9yg9iyX2QTzKuQM7T4xlBoeUP/J8uiFkqxkcWndWi+W7bXdPbt27Q==} resolution: {integrity: sha512-z4mQK9dAN6byRA/vsSgQiPeuO63wdiDxZ9yg9iyX2QTzKuQM7T4xlBoeUP/J8uiFkqxkcWndWi+W7bXdPbt27Q==}
@@ -1058,11 +1048,11 @@ packages:
resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==}
engines: {node: '>=8'} engines: {node: '>=8'}
discord-api-types@0.38.37: discord-api-types@0.37.119:
resolution: {integrity: sha512-Cv47jzY1jkGkh5sv0bfHYqGgKOWO1peOrGMkDFM4UmaGMOTgOW8QSexhvixa9sVOiz8MnVOBryWYyw/CEVhj7w==} resolution: {integrity: sha512-WasbGFXEB+VQWXlo6IpW3oUv73Yuau1Ig4AZF/m13tXcTKnMpc/mHjpztIlz4+BM9FG9BHQkEXiPto3bKduQUg==}
discord.js@14.25.1: discord.js@14.18.0:
resolution: {integrity: sha512-2l0gsPOLPs5t6GFZfQZKnL1OJNYFcuC/ETWsW4VtKVD/tg4ICa9x+jb9bkPffkMdRpRpuUaO/fKkHCBeiCKh8g==} resolution: {integrity: sha512-SvU5kVUvwunQhN2/+0t55QW/1EHfB1lp0TtLZUSXVHDmyHTrdOj5LRKdR0zLcybaA15F+NtdWuWmGOX9lE+CAw==}
engines: {node: '>=18'} engines: {node: '>=18'}
doctrine@2.1.0: doctrine@2.1.0:
@@ -2454,8 +2444,8 @@ packages:
undici-types@6.20.0: undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
undici@6.21.3: undici@6.21.1:
resolution: {integrity: sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==} resolution: {integrity: sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==}
engines: {node: '>=18.17'} engines: {node: '>=18.17'}
unpipe@1.0.0: unpipe@1.0.0:
@@ -2650,12 +2640,12 @@ snapshots:
'@babel/helper-validator-identifier@7.25.9': {} '@babel/helper-validator-identifier@7.25.9': {}
'@discordjs/builders@1.13.1': '@discordjs/builders@1.10.1':
dependencies: dependencies:
'@discordjs/formatters': 0.6.2 '@discordjs/formatters': 0.6.0
'@discordjs/util': 1.2.0 '@discordjs/util': 1.1.1
'@sapphire/shapeshift': 4.0.0 '@sapphire/shapeshift': 4.0.0
discord-api-types: 0.38.37 discord-api-types: 0.37.119
fast-deep-equal: 3.1.3 fast-deep-equal: 3.1.3
ts-mixer: 6.0.4 ts-mixer: 6.0.4
tslib: 2.8.1 tslib: 2.8.1
@@ -2664,35 +2654,33 @@ snapshots:
'@discordjs/collection@2.1.1': {} '@discordjs/collection@2.1.1': {}
'@discordjs/formatters@0.6.2': '@discordjs/formatters@0.6.0':
dependencies: dependencies:
discord-api-types: 0.38.37 discord-api-types: 0.37.119
'@discordjs/rest@2.6.0': '@discordjs/rest@2.4.3':
dependencies: dependencies:
'@discordjs/collection': 2.1.1 '@discordjs/collection': 2.1.1
'@discordjs/util': 1.2.0 '@discordjs/util': 1.1.1
'@sapphire/async-queue': 1.5.5 '@sapphire/async-queue': 1.5.5
'@sapphire/snowflake': 3.5.3 '@sapphire/snowflake': 3.5.3
'@vladfrangu/async_event_emitter': 2.4.6 '@vladfrangu/async_event_emitter': 2.4.6
discord-api-types: 0.38.37 discord-api-types: 0.37.119
magic-bytes.js: 1.10.0 magic-bytes.js: 1.10.0
tslib: 2.8.1 tslib: 2.8.1
undici: 6.21.3 undici: 6.21.1
'@discordjs/util@1.2.0': '@discordjs/util@1.1.1': {}
dependencies:
discord-api-types: 0.38.37
'@discordjs/ws@1.2.3': '@discordjs/ws@1.2.1':
dependencies: dependencies:
'@discordjs/collection': 2.1.1 '@discordjs/collection': 2.1.1
'@discordjs/rest': 2.6.0 '@discordjs/rest': 2.4.3
'@discordjs/util': 1.2.0 '@discordjs/util': 1.1.1
'@sapphire/async-queue': 1.5.5 '@sapphire/async-queue': 1.5.5
'@types/ws': 8.18.0 '@types/ws': 8.18.0
'@vladfrangu/async_event_emitter': 2.4.6 '@vladfrangu/async_event_emitter': 2.4.6
discord-api-types: 0.38.37 discord-api-types: 0.37.119
tslib: 2.8.1 tslib: 2.8.1
ws: 8.18.1 ws: 8.18.1
transitivePeerDependencies: transitivePeerDependencies:
@@ -3676,23 +3664,22 @@ snapshots:
dependencies: dependencies:
path-type: 4.0.0 path-type: 4.0.0
discord-api-types@0.38.37: {} discord-api-types@0.37.119: {}
discord.js@14.25.1: discord.js@14.18.0:
dependencies: dependencies:
'@discordjs/builders': 1.13.1 '@discordjs/builders': 1.10.1
'@discordjs/collection': 1.5.3 '@discordjs/collection': 1.5.3
'@discordjs/formatters': 0.6.2 '@discordjs/formatters': 0.6.0
'@discordjs/rest': 2.6.0 '@discordjs/rest': 2.4.3
'@discordjs/util': 1.2.0 '@discordjs/util': 1.1.1
'@discordjs/ws': 1.2.3 '@discordjs/ws': 1.2.1
'@sapphire/snowflake': 3.5.3 '@sapphire/snowflake': 3.5.3
discord-api-types: 0.38.37 discord-api-types: 0.37.119
fast-deep-equal: 3.1.3 fast-deep-equal: 3.1.3
lodash.snakecase: 4.1.1 lodash.snakecase: 4.1.1
magic-bytes.js: 1.10.0
tslib: 2.8.1 tslib: 2.8.1
undici: 6.21.3 undici: 6.21.1
transitivePeerDependencies: transitivePeerDependencies:
- bufferutil - bufferutil
- utf-8-validate - utf-8-validate
@@ -5344,7 +5331,7 @@ snapshots:
undici-types@6.20.0: {} undici-types@6.20.0: {}
undici@6.21.3: {} undici@6.21.1: {}
unpipe@1.0.0: {} unpipe@1.0.0: {}
+62
View File
@@ -0,0 +1,62 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { AtpAgent } from "@atproto/api";
import pkg from "@slack/bolt";
import { Client, Events } from "discord.js";
import { scheduleJob } from "node-schedule";
import { serve } from "./server/serve.js";
import { getMommy } from "./utils/getMommy.js";
import { logger } from "./utils/logger.js";
const { App, FileInstallationStore } = pkg;
const discord = new Client({ intents: [] });
discord.on(Events.ClientReady, () => {
void logger.log("info", "Connected to Discord!");
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises -- This is intentional.
discord.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) {
return;
}
await interaction.deferReply();
const name = interaction.options.getString("name");
const response = await getMommy(name ?? undefined);
await interaction.editReply(response);
});
const slack = new App({
clientId: process.env.SLACK_CLIENT_ID ?? "",
clientSecret: process.env.SLACK_CLIENT_SECRET ?? "",
installationStore: new FileInstallationStore(),
installerOptions: {
directInstall: true,
},
scopes: ["commands", "chat:write"],
signingSecret: process.env.SLACK_SIGNING_SECRET ?? "",
stateSecret: process.env.SLACK_STATE_SECRET ?? "",
});
slack.command("/mommy", async ({ ack, body, respond }) => {
await ack();
const response = await getMommy(body.text);
await respond(response);
});
const bsky = new AtpAgent({
service: "https://bsky.social",
});
await discord.login(process.env.DISCORD_TOKEN);
await slack.start(8010);
await logger.log("info", "Connected to Slack!");
await bsky.login({
identifier: "mommy.naomi.party",
password: process.env.BSKY_PASSWORD ?? "",
});
await logger.log("info", "Connected to bsky.social!");
scheduleJob("0 9 * * *", async () => {
const response = await getMommy();
await bsky.post({
text: response,
});
await logger.log("info", "Posted to bsky.social!");
});
serve();
+72
View File
@@ -0,0 +1,72 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import fastify from "fastify";
import { logger } from "../utils/logger.js";
const html = `<!DOCTYPE html>
<html>
<head>
<title>Mommy Bot</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Mommy loves you~!" />
<script src="https://cdn.nhcarrigan.com/headers/index.js" async defer></script>
</head>
<body>
<main>
<h1>Mommy Bot</h1>
<section>
<p>Mommy loves you~!</p>
<a href="https://slack.com/oauth/v2/authorize?client_id=8569765106322.8554301974567&scope=chat:write,commands&user_scope="><img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" /></a>
</section>
<section>
<h2>Links</h2>
<p>
<a href="https://git.nhcarrigan.com/nhcarrigan/mommy-bot">
<i class="fa-solid fa-code"></i> Source Code
</a>
</p>
<p>
<a href="https://docs.nhcarrigan.com/">
<i class="fa-solid fa-book"></i> Documentation
</a>
</p>
<p>
<a href="https://chat.nhcarrigan.com">
<i class="fa-solid fa-circle-info"></i> Support
</a>
</p>
</section>
</main>
</body>
</html>`;
/**
* Starts up a web server for health monitoring.
*/
export const serve = () => {
try {
const server = fastify({
logger: false,
});
server.get("/", (_request, response) => {
response.header("Content-Type", "text/html");
response.send(html);
});
server.listen({ port: 8009 }, (error) => {
if (error) {
void logger.error("instantiate server", error);
return;
}
void logger.log("debug", "Server listening on port 8009.");
});
}
catch (error) {
if (error instanceof Error) {
void logger.error("instantiate server", error);
return;
}
void logger.error("instantiate server", new Error("Unknown error"));
}
};
+20
View File
@@ -0,0 +1,20 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { isProfane } from "no-profanity";
/**
* Fetches a mommy quote from the API.
* @param name - The user's name, if provided.
* @returns The mommy quote.
*/
export const getMommy = async (name = "dear") => {
const finalName = isProfane(name)
? "dear"
: name;
const url = `https://mommy.nhcarrigan.com/api?name=${finalName}`;
const request = await fetch(url);
const response = await request.text();
return response;
};
+7
View File
@@ -0,0 +1,7 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { Logger } from "@nhcarrigan/logger";
export const logger = new Logger("Mommy", process.env.LOG_TOKEN ?? "");
+1 -2
View File
@@ -12,7 +12,6 @@ import { serve } from "./server/serve.js";
import { getMommy } from "./utils/getMommy.js"; import { getMommy } from "./utils/getMommy.js";
import { logger } from "./utils/logger.js"; import { logger } from "./utils/logger.js";
// eslint-disable-next-line @typescript-eslint/naming-convention -- Classes.
const { App, FileInstallationStore } = pkg; const { App, FileInstallationStore } = pkg;
const discord = new Client({ intents: [ ] }); const discord = new Client({ intents: [ ] });
@@ -74,7 +73,7 @@ scheduleJob("0 9 * * *", async() => {
await bsky.post({ await bsky.post({
text: response, text: response,
}); });
await logger.log("info", "Posted to bsky!"); await logger.log("info", "Posted to bsky.social!");
}); });
serve(); serve();
+28 -40
View File
@@ -9,52 +9,40 @@ import { logger } from "../utils/logger.js";
const html = `<!DOCTYPE html> const html = `<!DOCTYPE html>
<html> <html>
<head>
<head> <title>Mommy Bot</title>
<title>Mommy Bot</title> <meta charset="utf-8" />
<meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="description" content="Mommy loves you~!" />
<meta name="description" content="Mommy loves you~!" /> <script src="https://cdn.nhcarrigan.com/headers/index.js" async defer></script>
<script src="https://cdn.nhcarrigan.com/headers/index.js" async defer></script> </head>
</head> <body>
<main>
<body>
<main>
<h1>Mommy Bot</h1> <h1>Mommy Bot</h1>
<img src="https://cdn.nhcarrigan.com/new-avatars/mommy-full.png" width="250" alt="Mommy" />
<section> <section>
<p>Mommy loves you~!</p> <p>Mommy loves you~!</p>
<a href="https://mommy-slack.nhcarrigan.com/slack/install" style="display: inline-block; background-color: #ffffff; color: black; padding: 10px 20px; text-decoration: none; border-radius: 4px; margin: 5px;"> <a href="https://mommy-slack.nhcarrigan.com/slack/install"><img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" /></a>
<i class="fab fa-slack"></i> Add to Slack
</a>
<a href="https://discord.com/oauth2/authorize?client_id=1347642447643017289" class="social-button discord-button" style="display: inline-block; background-color: #5865F2; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; margin: 5px;">
<i class="fab fa-discord"></i> Add to Discord
</a>
<a href="https://bsky.app/profile/mommy.naomi.party" class="social-button bluesky-button" style="display: inline-block; background-color: #0085FF; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; margin: 5px;">
<i class="fab fa-bluesky"></i> Follow on Bluesky
</a>
</section> </section>
<section> <section>
<h2>Links</h2> <h2>Links</h2>
<p> <p>
<a href="https://git.nhcarrigan.com/nhcarrigan/mommy-bot"> <a href="https://git.nhcarrigan.com/nhcarrigan/mommy-bot">
<i class="fa-solid fa-code"></i> Source Code <i class="fa-solid fa-code"></i> Source Code
</a> </a>
</p> </p>
<p> <p>
<a href="https://docs.nhcarrigan.com/"> <a href="https://docs.nhcarrigan.com/">
<i class="fa-solid fa-book"></i> Documentation <i class="fa-solid fa-book"></i> Documentation
</a> </a>
</p> </p>
<p> <p>
<a href="https://chat.nhcarrigan.com"> <a href="https://chat.nhcarrigan.com">
<i class="fa-solid fa-circle-info"></i> Support <i class="fa-solid fa-circle-info"></i> Support
</a> </a>
</p> </p>
</section> </section>
</main> </main>
</body> </body>
</html>`; </html>`;
/** /**