forked from colin/resume
update to rules and tests
This commit is contained in:
parent
5ac1c24481
commit
77517079a7
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
description:
|
||||||
|
globs: *.js,*.css
|
||||||
|
alwaysApply: false
|
||||||
|
---
|
||||||
|
# Asset Hashing and CSP Update Rule
|
||||||
|
|
||||||
|
This rule ensures that all `.js` and `.css` assets are properly hashed and their integrity hashes are updated in `index.html` and added to the Content Security Policy (CSP) in the `Caddyfile` during every build and push process.
|
||||||
|
|
||||||
|
## Process to Follow
|
||||||
|
|
||||||
|
1. **Hash Calculation**: Before building the Docker image, calculate the SHA256 hash for each `.js` and `.css` file in the `docker/resume/` directory using a command like `shasum -a 256 filename | awk '{print $1}' | xxd -r -p | base64`.
|
||||||
|
2. **Update index.html**: Update the `integrity` attribute in the `<script>` and `<link>` tags in `index.html` with the new hashes for each respective file.
|
||||||
|
3. **Update CSP in Caddyfile**: Ensure the CSP in the `Caddyfile` includes the hashes for all scripts and styles under `script-src` and `style-src` directives respectively.
|
||||||
|
4. **Automate in Build Script**: Modify the `build-test-deploy.sh` script to automate the hashing and updating process before the Docker build step.
|
||||||
|
5. **Verification**: After updating, verify that the hashes in `index.html` and `Caddyfile` match the calculated hashes to prevent deployment with mismatched integrity.
|
||||||
|
|
||||||
|
## Relevant Files
|
||||||
|
- [docker/resume/index.html](mdc:docker/resume/index.html)
|
||||||
|
- [docker/resume/Caddyfile](mdc:docker/resume/Caddyfile)
|
||||||
|
- [build-test-deploy.sh](mdc:build-test-deploy.sh)
|
||||||
|
|
||||||
|
This rule must be followed to maintain security integrity and prevent CSP violations during deployment.
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
description:
|
||||||
|
globs:
|
||||||
|
alwaysApply: false
|
||||||
|
---
|
||||||
|
# Test Suite Integrity Rule
|
||||||
|
|
||||||
|
This rule ensures that the test suite for the project contains meaningful tests that perform actual checks and validations, rather than being empty placeholder boilerplate. All tests MUST do SOMETHING significant to verify the functionality, security, or performance of the application.
|
||||||
|
|
||||||
|
## Guidelines to Follow
|
||||||
|
|
||||||
|
1. **Non-Empty Tests**: Every test file in the `tests/` directory must contain at least one test case that performs a specific validation or check. Empty test files or test cases with no assertions are not allowed.
|
||||||
|
2. **Meaningful Assertions**: Each test must include assertions or expectations that verify the behavior of the application. Tests should not simply run without checking outcomes (e.g., no empty `expect()` calls or trivial assertions like `expect(true).toBe(true)`).
|
||||||
|
3. **Coverage of Key Features**: The test suite must cover critical aspects of the application, including but not limited to:
|
||||||
|
- Accessibility (WCAG compliance)
|
||||||
|
- Security headers and CSP compliance
|
||||||
|
- Functional features like the PDF download button
|
||||||
|
- Performance metrics (via tools like Lighthouse)
|
||||||
|
4. **Regular Review**: Before running `build-test-deploy.sh`, review the test suite to ensure no placeholder or boilerplate tests remain. If a test is temporarily skipped or incomplete, it must be annotated with a clear `TODO` comment explaining the reason and a plan for completion.
|
||||||
|
5. **Automation in Build Script**: If possible, add a pre-test step in `build-test-deploy.sh` to scan test files for empty or placeholder content (e.g., using grep to detect empty test blocks or missing assertions) and fail the build if such issues are found.
|
||||||
|
|
||||||
|
## Relevant Files and Directories
|
||||||
|
- [tests/](mdc:tests)
|
||||||
|
- [build-test-deploy.sh](mdc:build-test-deploy.sh)
|
||||||
|
|
||||||
|
This rule must be adhered to in order to maintain a robust and reliable testing framework that ensures the quality and security of the application.
|
|
@ -67,17 +67,28 @@ cd ..
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
npm run setup
|
npm run setup
|
||||||
if npm test; then
|
# Run tests and save output for AI parsing
|
||||||
|
if npm test > test_output.log 2>&1; then
|
||||||
echo "Tests passed. Committing and pushing changes."
|
echo "Tests passed. Committing and pushing changes."
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Automated build, test, and deploy"
|
git commit -m "Automated build, test, and deploy"
|
||||||
git push
|
git push
|
||||||
else
|
else
|
||||||
echo "Tests failed. Not deploying."
|
echo "Tests failed. Not deploying."
|
||||||
|
cat test_output.log
|
||||||
docker rm -f $CONTAINER_NAME
|
docker rm -f $CONTAINER_NAME
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Optionally open report in browser if available, but don't require interaction
|
||||||
|
echo "Test output saved to test_output.log for AI parsing."
|
||||||
|
if command -v open >/dev/null 2>&1; then
|
||||||
|
echo "Opening HTML report in browser (if available)..."
|
||||||
|
open http://localhost:9323 || echo "Could not open browser automatically. Please visit http://localhost:9323 to view the report."
|
||||||
|
else
|
||||||
|
echo "Browser opening not supported. Report available at http://localhost:9323 if a server is running."
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Cleaning up Docker container..."
|
echo "Cleaning up Docker container..."
|
||||||
docker rm -f $CONTAINER_NAME
|
docker rm -f $CONTAINER_NAME
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ COPY theme.js /srv/
|
||||||
COPY utils.js /srv/
|
COPY utils.js /srv/
|
||||||
COPY styles.css /srv/
|
COPY styles.css /srv/
|
||||||
COPY pdf-download.js /srv/
|
COPY pdf-download.js /srv/
|
||||||
|
COPY favicon.ico /srv/
|
||||||
|
|
||||||
# Expose port 8080
|
# Expose port 8080
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="description" content="Colin Knapp - Cybersecurity Expert and Software Developer Portfolio">
|
<meta name="description" content="Colin Knapp - Cybersecurity Expert and Software Developer Portfolio">
|
||||||
<title>Colin Knapp Portfolio</title>
|
<title>Colin Knapp Portfolio</title>
|
||||||
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
<link rel="stylesheet" href="styles.css" integrity="sha256-Ps1dklCHzk1leTAfqkeA64YDuDJxx5QZBjC2UQhSdz0=" crossorigin="anonymous">
|
<link rel="stylesheet" href="styles.css" integrity="sha256-Ps1dklCHzk1leTAfqkeA64YDuDJxx5QZBjC2UQhSdz0=" crossorigin="anonymous">
|
||||||
<script src="theme.js" integrity="sha256-anTkUs/oFZJulKUMaMjZlwaALEmPOP8op0psAo5Bhh8=" crossorigin="anonymous"></script>
|
<script src="theme.js" integrity="sha256-anTkUs/oFZJulKUMaMjZlwaALEmPOP8op0psAo5Bhh8=" crossorigin="anonymous"></script>
|
||||||
<script src="pdf-download.js" integrity="sha256-BASkmAmg7eoYCMd6odA6kQ8yGsFnoxaX48WbQvMkehs=" crossorigin="anonymous"></script>
|
<script src="pdf-download.js" integrity="sha256-BASkmAmg7eoYCMd6odA6kQ8yGsFnoxaX48WbQvMkehs=" crossorigin="anonymous"></script>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="description" content="Colin Knapp - Cybersecurity Expert and Software Developer Portfolio">
|
<meta name="description" content="Colin Knapp - Cybersecurity Expert and Software Developer Portfolio">
|
||||||
<title>Colin Knapp Portfolio</title>
|
<title>Colin Knapp Portfolio</title>
|
||||||
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
<link rel="stylesheet" href="styles.css" integrity="sha256-Ps1dklCHzk1leTAfqkeA64YDuDJxx5QZBjC2UQhSdz0=" crossorigin="anonymous">
|
<link rel="stylesheet" href="styles.css" integrity="sha256-Ps1dklCHzk1leTAfqkeA64YDuDJxx5QZBjC2UQhSdz0=" crossorigin="anonymous">
|
||||||
<script src="theme.js" integrity="sha256-anTkUs/oFZJulKUMaMjZlwaALEmPOP8op0psAo5Bhh8=" crossorigin="anonymous"></script>
|
<script src="theme.js" integrity="sha256-anTkUs/oFZJulKUMaMjZlwaALEmPOP8op0psAo5Bhh8=" crossorigin="anonymous"></script>
|
||||||
<script src="pdf-download.js" integrity="sha256-BASkmAmg7eoYCMd6odA6kQ8yGsFnoxaX48WbQvMkehs=" crossorigin="anonymous"></script>
|
<script src="pdf-download.js" integrity="sha256-BASkmAmg7eoYCMd6odA6kQ8yGsFnoxaX48WbQvMkehs=" crossorigin="anonymous"></script>
|
||||||
|
|
Loading…
Reference in New Issue