-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1546 from GSA/dev
Release v0.5.0.beta.1 (sprint 35)
- Loading branch information
Showing
40 changed files
with
416 additions
and
1,331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ on: | |
- dev | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
php-lint: | ||
name: PHP Lint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: TruffleHog Scan | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
pull_request: | ||
|
||
jobs: | ||
scan: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install GitHub CLI | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gh | ||
- name: Authenticate GitHub CLI | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} | ||
run: | | ||
gh auth setup-git | ||
- name: Run TruffleHog scan | ||
id: trufflehog_scan | ||
uses: trufflesecurity/[email protected] | ||
with: | ||
base: "" | ||
head: ${{ github.ref_name }} | ||
extra_args: --only-verified --json --entropy --max-depth=50 | ||
continue-on-error: true | ||
|
||
- name: Check TruffleHog Results | ||
id: check_results | ||
run: | | ||
if [ -f truffleHogResults.json ]; then | ||
echo "file_exists=true" >> $GITHUB_ENV | ||
else | ||
echo "file_exists=false" >> $GITHUB_ENV | ||
fi | ||
- name: Upload TruffleHog scan results | ||
if: always() && env.file_exists == 'true' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: trufflehog-results | ||
path: truffleHogResults.json | ||
|
||
- name: Convert JSON to Readable Report | ||
if: always() && env.file_exists == 'true' | ||
run: | | ||
jq -r '.results[] | "File: \(.path)\nCommit: \(.commit)\nDate: \(.date)\nReason: \(.reason)\n---------------------------"' truffleHogResults.json > truffleHogReport.txt | ||
- name: Upload Readable Report | ||
if: always() && env.file_exists == 'true' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: trufflehog-readable-report | ||
path: truffleHogReport.txt | ||
|
||
- name: Check for findings and create issue | ||
if: failure() && env.file_exists == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} | ||
run: | | ||
if jq -e '.results | length > 0' truffleHogResults.json > /dev/null; then | ||
echo "Secrets found. Creating GitHub issue." | ||
gh issue create --title "TruffleHog Scan Results" --body "$(cat truffleHogReport.txt)" --label "bug,security" --assignee "@me" | ||
exit 1 | ||
else | ||
echo "No secrets found or no results file." | ||
fi | ||
- name: Fail the job if any secrets are found | ||
if: steps.trufflehog_scan.outcome == 'failure' | ||
run: exit 1 |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 90 additions & 46 deletions
136
benefit-finder/cypress/e2e/usagov-public-site/links.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,108 @@ | ||
import * as utils from '../../support/utils' | ||
import * as BENEFITS_ELIBILITY_DATA from '../../fixtures/benefits-eligibility.json' | ||
|
||
describe('Verify correct status code when user navigates links', () => { | ||
// to be removed when uncaught exceptions are addressed | ||
Cypress.on('uncaught:exception', (_err, runnable) => { | ||
return false | ||
}) | ||
it('Verify success status code response for links in Death of a loved one English page', () => { | ||
const selectedData = | ||
BENEFITS_ELIBILITY_DATA['death-of-a-loved-one'].en.param | ||
const scenario = utils.encodeURIFromObject(selectedData) | ||
cy.visit(`benefit-finder/death?${scenario}`) | ||
cy.get('main a[href]').each(link => { | ||
cy.request(link.prop('href')) | ||
const localePaths = { | ||
en: [ | ||
{ key: 'death-of-a-loved-one', path: 'death' }, | ||
{ key: 'retirement', path: 'retirement' }, | ||
{ key: 'disability', path: 'disability' }, | ||
], | ||
es: [ | ||
{ key: 'death-of-a-loved-one', path: 'muerte' }, | ||
{ key: 'retirement', path: 'jubilacion' }, | ||
{ key: 'disability', path: 'discapacidad' }, | ||
], | ||
} | ||
|
||
const handlerequest = ({ testLink, link }) => { | ||
const url = testLink || link.prop('href') | ||
return cy | ||
.request({ | ||
url, | ||
failOnStatusCode: false, | ||
}) | ||
.then(response => { | ||
if (response.status === 200) { | ||
expect(response.status).to.eq(200) | ||
} else if (response.status === 403) { | ||
cy.get('body').children().its('length').should('be.gt', 0) | ||
} else if (response.status === 503) { | ||
throw new Error(`site down - gave a 503 ${url}`) | ||
} else if (response.status === 404) { | ||
throw new Error(`page not found - gave a 404 ${url}`) | ||
} else { | ||
cy.get('body').children().its('length').should('be.gt', 0) | ||
} | ||
}) | ||
} | ||
|
||
const validateErrorCodes = test => { | ||
// we verify site is alive and fail on 404 || 503 | ||
cy.get('#benefit-finder a[href]').each(link => { | ||
handlerequest({ link }) | ||
}) | ||
} | ||
|
||
it('Verify success status code response for links in Death of a Loved One Spanish page', () => { | ||
const selectedData = | ||
BENEFITS_ELIBILITY_DATA['death-of-a-loved-one'].es.param | ||
const scenario = utils.encodeURIFromObject(selectedData) | ||
cy.visit(`es/buscador-beneficios/muerte?${scenario}`) | ||
cy.get('main a[href]').each(link => { | ||
cy.request(link.prop('href')) | ||
}) | ||
const validateLinks = ({ selectedData, path }) => { | ||
const scenario = utils.encodeURIFromObject(selectedData) | ||
cy.visit(`${path}?${scenario}`) | ||
validateErrorCodes() | ||
} | ||
|
||
// to be removed when uncaught exceptions are addressed | ||
// eslint-disable-next-line n/handle-callback-err | ||
Cypress.on('uncaught:exception', (error, runnable) => { | ||
return false | ||
}) | ||
|
||
describe('Verify correct status code handling', () => { | ||
// negate validation on our functional code | ||
Cypress.on('fail', (error, runnable) => { | ||
if (JSON.stringify(error).includes('httpstat')) { | ||
// eslint-disable-next-line no-unused-expressions | ||
expect(error).to.not.be.undefined | ||
} else { | ||
throw error | ||
} | ||
}) | ||
|
||
it('Verify success status code response for links in Retirement English page', () => { | ||
const selectedData = BENEFITS_ELIBILITY_DATA.retirement.en.param | ||
const scenario = utils.encodeURIFromObject(selectedData) | ||
cy.visit(`benefit-finder/retirement?${scenario}`) | ||
cy.get('main a[href]').each(link => { | ||
cy.request(link.prop('href')) | ||
}) | ||
it(`handles 404 with an error`, () => { | ||
handlerequest({ testLink: 'https://httpstat.us/404' }) | ||
}) | ||
|
||
it('Verify success status code response for links in Retirement Spanish page', () => { | ||
const selectedData = BENEFITS_ELIBILITY_DATA.retirement.es.param | ||
const scenario = utils.encodeURIFromObject(selectedData) | ||
cy.visit(`es/buscador-beneficios/jubilacion?${scenario}`) | ||
cy.get('main a[href]').each(link => { | ||
cy.request(link.prop('href')) | ||
}) | ||
it(`handles 503 with an error`, () => { | ||
handlerequest({ testLink: 'https://httpstat.us/503' }) | ||
}) | ||
|
||
it(`handles 200 successfully`, () => { | ||
handlerequest({ testLink: 'https://httpstat.us/200' }) | ||
}) | ||
|
||
it(`handles any 403 successfully`, () => { | ||
handlerequest({ testLink: 'https://httpstat.us/403' }) | ||
}) | ||
|
||
it(`handles any other request successfully`, () => { | ||
handlerequest({ testLink: 'https://httpstat.us/201' }) | ||
}) | ||
}) | ||
|
||
it('Verify success status code response for links in Disability English page', () => { | ||
const selectedData = BENEFITS_ELIBILITY_DATA.disability.en.param | ||
const scenario = utils.encodeURIFromObject(selectedData) | ||
cy.visit(`benefit-finder/disability?${scenario}`) | ||
cy.get('main a[href]').each(link => { | ||
cy.request(link.prop('href')) | ||
describe('Verify correct status code when user navigates links in each locales', () => { | ||
localePaths.en.forEach(location => { | ||
it(`Verify success status code response for links in ${location.key} en page`, () => { | ||
validateLinks({ | ||
selectedData: BENEFITS_ELIBILITY_DATA[`${location.key}`].en.param, | ||
path: `benefit-finder/${location.path}`, | ||
}) | ||
}) | ||
}) | ||
|
||
it('Verify success status code response for links in Disability English page', () => { | ||
const selectedData = BENEFITS_ELIBILITY_DATA.disability.es.param | ||
const scenario = utils.encodeURIFromObject(selectedData) | ||
cy.visit(`es/buscador-beneficios/discapacidad?${scenario}`) | ||
cy.get('main a[href]').each(link => { | ||
cy.request(link.prop('href')) | ||
localePaths.es.forEach(location => { | ||
it(`Verify success status code response for links in ${location.key} es page`, () => { | ||
validateLinks({ | ||
selectedData: BENEFITS_ELIBILITY_DATA[`${location.key}`].en.param, | ||
path: `es/buscador-beneficios/${location.path}`, | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.