Skip to content

Commit 9e1e695

Browse files
author
kadraman
committed
Implement cookies banner and acceptance (fixes #11)
chore: update tests and GitHub Actions.
1 parent 3d2120b commit 9e1e695

5 files changed

Lines changed: 72 additions & 26 deletions

File tree

.github/workflows/debricked.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
# Create GitHub Action Secrets for your version of the application:
3-
# DEBRICKEN_TOKEN should be an API Access Token from your Debricked tenant.
3+
# DEBRICKED_TOKEN should be an API Access Token from your Debricked tenant.
44

5-
name: OSS SCA with Debricked
5+
name: OpenText SCA Core
66
permissions:
77
# required for all workflows
88
security-events: write
@@ -26,7 +26,7 @@ on:
2626
workflow_dispatch:
2727
inputs:
2828
runDebrickedScan:
29-
description: 'Carry out SCA scan using Debricked'
29+
description: 'Scan using OpenText Core SCA'
3030
required: true
3131
default: 'true'
3232

@@ -65,3 +65,16 @@ jobs:
6565
env:
6666
APP_NAME: ${{ env.DEFAULT_APP_NAME }}
6767
DEBRICKED_TOKEN: ${{ secrets.DEBRICKED_TOKEN }}
68+
69+
scan_frontend:
70+
stage: scan
71+
image: debricked/cli:2-resolution-debian
72+
script:
73+
- debricked scan "$COMPONENT_DIR" -r ${DEBRICKED_REPO} -b ${DEBRICKED_BRANCH} -t ${DEBRICKED_TOKEN} --sbom CycloneDX --sbom-output gl-sbom-cdx.json
74+
dependencies:
75+
- build_frontend
76+
allow_failure: true
77+
artifacts:
78+
reports:
79+
cyclonedx:
80+
- gl-sbom-cdx.json

.github/workflows/fod.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# It is recommended to create credentials with 'Security Lead' Role selected.
1515
# "Automated Audit preference" should be configured for the release's Static Scan Settings.
1616

17-
name: OpenText Application Secuirity Core
17+
name: OpenText Core Application Security
1818
permissions:
1919
# required for all workflows
2020
security-events: write
@@ -50,19 +50,19 @@ on:
5050
workflow_dispatch:
5151
inputs:
5252
runFoDSASTScan:
53-
description: 'Carry out SAST scan using Fortify on Demand'
53+
description: 'Carry out SAST scan using OpenText Core Application Security'
5454
required: false
5555
default: 'true'
5656
runFoDOSSScan:
57-
description: 'Carry out OSS scan using Fortify on Demand'
57+
description: 'Carry out OSS scan using OpenText Core Application Security'
5858
required: false
5959
default: 'true'
6060
deployApp:
61-
description: 'Deploy App'
61+
description: 'Deploy App to Azure'
6262
required: false
6363
default: 'true'
6464
runFoDDASTScan:
65-
description: 'Carry out DAST scan using Fortify on Demand'
65+
description: 'Carry out DAST scan using OpenText Core Application Security'
6666
required: false
6767
default: 'false'
6868

@@ -97,8 +97,8 @@ jobs:
9797
fi
9898
9999
Build-And-Unit-Test:
100-
# The type of runner that the job will run on
101100
runs-on: ubuntu-latest
101+
needs: [ Env-Prepare ]
102102
steps:
103103
- name: Checkout
104104
uses: actions/checkout@v4
@@ -156,7 +156,7 @@ jobs:
156156
# See: https://github.com/marketplace/actions/fortify-ast-scan
157157
#
158158
- name: Run Fortify on Demand SAST Scan
159-
uses: fortify/github-action@v1
159+
uses: fortify/github-action@v2
160160
with:
161161
sast-scan: true
162162
debricked-sca-scan: false # we will do this separately using fcli
@@ -202,7 +202,7 @@ jobs:
202202
- name: Checkout
203203
uses: actions/checkout@v4
204204
- name: Setup Fortify tools
205-
uses: fortify/github-action/setup@v1
205+
uses: fortify/github-action/setup@v2
206206
with:
207207
#tool-definitions: https://github.com/fortify/tool-definitions/releases/download/v1/tool-definitions.yaml.zip
208208
export-path: true
@@ -252,16 +252,16 @@ jobs:
252252
# app-name: ${{ env.AZURE_WEBAPP_NAME }}
253253
# publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_94429323A56E479BA44DAB94865DCF4A }}
254254

255-
#Functional-Test:
256-
# runs-on: ubuntu-latest
257-
# if: ${{ always() }}
258-
# needs: [ Env-Prepare, Deploy-App ]
259-
# env:
260-
# FOD_RELEASE: ${{ needs.Env-Prepare.outputs.FOD_RELEASE }}
261-
# FOD_PARENT_RELEASE: ${{ needs.Env-Prepare.outputs.FOD_PARENT_RELEASE }}
262-
# steps:
263-
# - name: Checkout
264-
# uses: actions/checkout@v4
255+
Functional-Test:
256+
runs-on: ubuntu-latest
257+
if: ${{ always() }}
258+
needs: [ Env-Prepare, Deploy-App ]
259+
env:
260+
FOD_RELEASE: ${{ needs.Env-Prepare.outputs.FOD_RELEASE }}
261+
FOD_PARENT_RELEASE: ${{ needs.Env-Prepare.outputs.FOD_PARENT_RELEASE }}
262+
steps:
263+
- name: Checkout
264+
uses: actions/checkout@v4
265265

266266
FoD-DAST-Scan:
267267
runs-on: ubuntu-latest
@@ -274,7 +274,7 @@ jobs:
274274
- name: Checkout
275275
uses: actions/checkout@v4
276276
- name: Setup Fortify tools
277-
uses: fortify/github-action/setup@v1
277+
uses: fortify/github-action/setup@v2
278278
with:
279279
#tool-definitions: https://github.com/fortify/tool-definitions/releases/download/v1/tool-definitions.yaml.zip
280280
export-path: true
@@ -305,7 +305,7 @@ jobs:
305305
- name: Checkout
306306
uses: actions/checkout@v4
307307
- name: Setup Fortify tools
308-
uses: fortify/github-action/setup@v1
308+
uses: fortify/github-action/setup@v2
309309
with:
310310
#tool-definitions: https://github.com/fortify/tool-definitions/releases/download/v1/tool-definitions.yaml.zip
311311
export-path: true

iwa/templates/base.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ <h4></h4>
288288
</div>
289289
</footer>
290290

291+
{% include "includes/cookies.html" ignore missing %}
292+
291293
<script src="{{ url_for('static', filename='js/lib/jquery.min.js') }}" type="text/javascript"></script>
292294
<script src="{{ url_for('static', filename='js/lib/bootstrap.bundle.min.js') }}" type="text/javascript"></script>
293295
<script src="{{ url_for('static', filename='js/lib/owl.carousel.min.js') }}" type="text/javascript"></script>
@@ -305,16 +307,31 @@ <h4></h4>
305307
$(document).ready(function () {
306308
$('#subscribe-newsletter').SubscribeNewsletter();
307309
$('#shopping-cart-count').CartCount();
310+
if (!localStorage.getItem('cookieConsent')) {
311+
var cookieModal = new bootstrap.Modal($('#cookieConsentModal')[0]);
312+
cookieModal.show();
313+
$('#acceptCookies').on('click', function () {
314+
localStorage.setItem('cookieConsent', 'true');
315+
cookieModal.hide();
316+
});
317+
}
318+
$('.alert').each(function () {
319+
new bootstrap.Alert(this);
320+
let alert_timeout = $(this).data('timeout');
321+
setTimeout(() => {
322+
bootstrap.Alert.getInstance(this).close();
323+
}, +alert_timeout);
324+
});
308325
});
309326
})(jQuery);
310-
let alert_list = document.querySelectorAll('.alert')
327+
/*let alert_list = document.querySelectorAll('.alert')
311328
alert_list.forEach(function(alert) {
312329
new bootstrap.Alert(alert);
313330
let alert_timeout = alert.getAttribute('data-timeout');
314331
setTimeout(() => {
315332
bootstrap.Alert.getInstance(alert).close();
316333
}, +alert_timeout);
317-
});
334+
});*/
318335
</script>
319336

320337
{% block scripts %} {% endblock %}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!-- Cookie Consent Modal -->
2+
<div class="modal fade" id="cookieConsentModal" tabindex="-1" aria-labelledby="cookieConsentLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
3+
<div class="modal-dialog modal-dialog-centered">
4+
<div class="modal-content">
5+
<div class="modal-header">
6+
<h5 class="modal-title" id="cookieConsentLabel">We use cookies</h5>
7+
</div>
8+
<div class="modal-body">
9+
This website uses cookies to ensure you get the best experience. By clicking "Accept", you consent to our use of cookies.
10+
</div>
11+
<div class="modal-footer">
12+
<button type="button" id="acceptCookies" class="btn btn-primary">Accept</button>
13+
</div>
14+
</div>
15+
</div>
16+
</div>

tests/functional/test_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_home_page(test_client):
2626
"""
2727
response = test_client.get('/')
2828
assert response.status_code == 200
29-
assert b"Welcome To IWA Pharmacy Direct" in response.data
29+
assert b"Welcome To <br/>IWA Pharmacy Direct" in response.data
3030
assert b"Register" in response.data
3131
assert b"Shop Now" in response.data
3232

0 commit comments

Comments
 (0)