Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Dev #124

Merged
merged 47 commits into from
Apr 5, 2019
Merged

Dev #124

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e6acd31
Add the utf-8 byte order marker to simplify issues with loading to Excel
obrien-j Oct 6, 2018
9693d16
Brought tests suites inline with models.py, handle the utf-8 BOM, and…
obrien-j Oct 6, 2018
e41b1da
Whoops. params where they should have been.
obrien-j Oct 6, 2018
2e1905b
Minor changes to cache invalidation to get rid of write access rqmt.
obrien-j Oct 10, 2018
758de1f
ugh tests.
obrien-j Oct 10, 2018
12af9bc
get_cache should be type-hinting a str return, not bool. Also, I was …
obrien-j Oct 13, 2018
1a6a43a
sigh. tests. remember the tests.
obrien-j Oct 13, 2018
b5d2267
- removed Beta banner
sayaHub Oct 24, 2018
29f63c4
Merge branch 'cache-rewrite' into dev
sayaHub Oct 24, 2018
f38223b
Merge branch 'utf-8-fixups' into dev
sayaHub Oct 24, 2018
5c5e836
Merge branch 'hotfix-align-with-canada-req' into dev
sayaHub Oct 24, 2018
b4ec421
- removed temporary Google Analytics
sayaHub Oct 25, 2018
58c2077
Merge branch 'hotfix-csp-implementation' into dev
sayaHub Oct 25, 2018
23ada97
forgot one inline onclick javascript
sayaHub Oct 26, 2018
78820f8
Merge branch 'hotfix-csp-implementation' into dev
sayaHub Oct 26, 2018
68a7a39
- implemented a whitelist for report names that can be call via the a…
sayaHub Oct 31, 2018
08e54ba
- forgot one file
sayaHub Oct 31, 2018
be00f51
Merge branch 'hotfix-reports-name-whitelist' into dev
sayaHub Oct 31, 2018
dfb9c03
build package for public app
dsamojlenko Oct 31, 2018
aee2702
fix syntax errors
dsamojlenko Oct 31, 2018
5114392
fire new job names
dsamojlenko Oct 31, 2018
6a684c7
added logic to only display the donut for Public users
sayaHub Nov 5, 2018
5b69391
Merge remote-tracking branch 'remotes/origin/build_public_package' in…
sayaHub Nov 5, 2018
61f60c9
Merge branch 'hotfix-dual-app' into dev
sayaHub Nov 5, 2018
17c5cd5
forgot to remove bold for links for modal (How to read this table?)
sayaHub Nov 7, 2018
44b2076
removed some unwanted space
sayaHub Nov 9, 2018
ef1e55f
put back Beta Banner
sayaHub Nov 19, 2018
9694aab
Merge branch 'hotfix-align-with-canada-req' into dev
sayaHub Nov 19, 2018
9d841c5
Minor tweaks to config to enable usage of Azure Managed Service Ident…
Nov 20, 2018
0fd0cbb
this time with updated req's
obrien-j Nov 20, 2018
1768344
local ci would be great when you're sleep deprived.
obrien-j Nov 20, 2018
1ea740a
removed secret name out of code
sayaHub Nov 23, 2018
178e595
Merge branch 'azure_msi' into dev
sayaHub Nov 23, 2018
aa2db55
Removed headers due to duplication..
obrien-j Jan 3, 2019
22da9d4
Security Update: pyyaml bump to pull in safe_load
obrien-j Jan 6, 2019
3909b87
Security Update: pyyaml version bump
obrien-j Jan 6, 2019
3b2e38a
Paginate scroll to top
timarney Jan 7, 2019
ad84e85
Merge branch 'to-top' into dev
sayaHub Jan 9, 2019
7fa48b3
Merge branches 'duplicate-headers' and 'pyyaml_security_bump' into dev
sayaHub Jan 9, 2019
d580ced
add semi-colon
timarney Jan 10, 2019
d5aa841
Merge branch 'to-top' into dev
sayaHub Jan 11, 2019
797e496
- Implementation of Google Tag Manager
sayaHub Mar 27, 2019
7ded3e4
fix typo
sayaHub Mar 27, 2019
b9b29c1
fix data-domain, can't use comma to enclose value, break if value hav…
sayaHub Mar 27, 2019
c4f6c18
removed CSP policies from HTML header. CSP is now implemented on Ngin…
sayaHub Apr 2, 2019
f6e1980
- some cleanup before merge to Master branch
sayaHub Apr 2, 2019
c06c7d0
- to fix Alerts from LGTM
sayaHub Apr 2, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
docker push "${DOCKER_REGISTRY}/${DOCKER_NAMESPACE}/${CIRCLE_PROJECT_REPONAME}:latest"
name: "Build and Deploy Website Docker Image"
working_directory: ~/repo
build_package:
build_internal_package:
docker:
- image: cdssnc/track-web-build:0.1.0
working_directory: /opt/apps/track-web
Expand All @@ -58,12 +58,25 @@ jobs:
- store_artifacts:
path: /opt/apps/track-web/track-web.tar.gz
destination: track-web.tar.gz

build_external_package:
docker:
- image: cdssnc/track-web-build:0.1.0
working_directory: /opt/apps/track-web-public
steps:
- checkout
- run:
command: sh deploy/build-env-public.sh
- store_artifacts:
path: /opt/apps/track-web-public/track-web-public.tar.gz
destination: track-web-public.tar.gz
workflows:
version: 2
tracker:
jobs:
- track_web
- build_package:
- build_internal_package:
requires:
- track_web
- build_external_package:
requires:
- track_web
9 changes: 9 additions & 0 deletions deploy/build-env-public.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
WORKDIR=${1:-"/opt/apps/track-web-public"}
mkdir -p $WORKDIR
cd $WORKDIR
python3 -m venv .venv
. .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
tar -czvf track-web-public.tar.gz .venv track
rm -rf .venv
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
flask==0.12.4
gunicorn==19.6.0
pyyaml==3.12
pyyaml==3.13
python-slugify==1.2.1
Flask-PyMongo==0.5.1
flask-compress==1.4.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
install_requires=[
'flask==0.12.4',
'gunicorn==19.6.0',
'pyyaml==3.12',
'pyyaml==3.13',
'python-slugify==1.2.1',
'pymongo==3.7.0',
'Flask-PyMongo==0.5.1',
Expand Down
2 changes: 2 additions & 0 deletions track/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Config:
def init_app(app):
pass



class ProductionConfig(Config):

CACHE_TYPE = "filesystem"
Expand Down
5 changes: 5 additions & 0 deletions track/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pkg_resources
import yaml
import datetime
import os
from track import models
from track.data import FIELD_MAPPING
from babel.dates import format_date
Expand Down Expand Up @@ -56,3 +57,7 @@ def percent(num, denom):
@app.template_filter("percent_not")
def percent_not(num, denom):
return (100 - round((num / denom) * 100))

@app.template_filter("fetch_env")
def fetch_env(value):
return os.getenv(value)
4 changes: 1 addition & 3 deletions track/static/js/dataTables.downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ $.fn.dataTable.Download = function ( inst ) {
if (drawnOnce) return;

var elem = "" +
"<a onClick=\"gtag('event', 'download', { event_category: 'Download / Télécharger', event_action: 'Download / Télécharger CSV'});\" class=\"text-https-blue hover:text-black font-bold\" href=\"" + csv + "\" download>" +
text +
"</a>";
"<a class=\"text-https-blue hover:text-black font-bold\" href=\"" + csv + "\" download>" + text +"</a>";

container.html(elem);
drawnOnce = true;
Expand Down
6 changes: 2 additions & 4 deletions track/static/js/https/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ $(function () {
// determines whether remote fetching has to happen
var fetch = !(loneDomain(row));

return n(row.domain) + "<div class=\"mt-2\">" + l("", "#", showHideText(true, row), "onclick=\"return false\" data-fetch=\"" + fetch + "\" data-domain=\"" + row.domain + "\"") + "</div>";
return n(row.domain) + "<div class=\"mt-2\">" + l("", "#", showHideText(true, row), "data-fetch=\"" + fetch + "\" data-domain=\"" + row.domain + "\"") + "</div>";
};

var showHideText = function(show, row) {
Expand Down Expand Up @@ -369,9 +369,7 @@ $(function () {
};

var l = function(base_domain, href, text, extra) {
// if base domain is provided, CSV download, so track with gtag
if(base_domain != "") return "<a onClick=\"gtag('event', 'download', { event_category: 'Download / Télécharger', event_action: 'Download / Télécharger CSV " + base_domain + "'});\" href=\"" + href + "\" target=\"blank\" " + extra + ">" + text + "</a>";


return "<a href=\"" + href + "\" target=\"blank\" " + extra + ">" + text + "</a>";
};

Expand Down
75 changes: 75 additions & 0 deletions track/static/js/https/donuts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
function generate_chart() {
var chart = d3.select('.compliant');
var width = chart.attr("data-width");
if (width == null)
width = calculate_width();
width = parseInt(width);
var height = width * 1.2;
var radius = Math.min(width, height) / 2;
var color = d3.scale.ordinal()
.range(["#0071e1", "#888888"]);
var arc = d3.svg.arc()
.outerRadius(radius)
.innerRadius(radius - 40);
var pie = d3.layout.pie()
.value(function (d) {
return d.value;
})
.sort(null);
chart = chart
.append('svg')
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + (width / 2) + "," + (height / 2) + ")");
d3.json("/data/reports/https.json", function (error, data) {
// calculate % client-side
var compliant = Math.round((data.enforces / data.eligible) * 100);
// just abort and leave it blank if something's wrong
// (instead of showing "NaN%" visually)
if (isNaN(compliant))
return;
var pie_data = [
{status: 'active', value: compliant},
{status: 'inactive', value: (100-compliant)},
]
var g = chart.selectAll(".arc")
.data(pie(pie_data))
.enter().append("g")
.attr("class", "arc");
g.append("path")
.style("fill", function(d) {
return color(d.data.status);
})
.transition().delay(function(d, i) {
return i *400;
}).duration(400)
.attrTween('d', function(d) {
var i = d3.interpolate(d.startAngle+ 0.1, d.endAngle);
return function(t) {
d.endAngle = i(t);
return arc(d);
}
});
g.append("text")
.attr("text-anchor", "middle")
.attr("class", "text-5xl font-bold")
.attr("dy", "0.4em")
.attr("fill", "black")
.text(function(d){
return "" + pie_data[0].value + "%";
});
});
};

function calculate_width() {
var window_width = $(window).width();

if(window_width < 769)
return 250;
else
return 287;
}

generate_chart();

4 changes: 2 additions & 2 deletions track/static/js/https/organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ $(document).ready(function () {

var link = function(link_text) {
return "" +
"<a onClick=\"gtag('event', 'Search', { event_category: 'Search / Rechercher', event_action: 'Search / Rechercher " + row["name_" + language] + "'});\" href=\"/" + language + "/" + text.domains[language] + "/#" +
QueryString.stringify({q: row["name_" + language]}) + "\">" +
"<a href=\"/" + language + "/" + text.domains[language] + "/#" +
QueryString.stringify({q: row["name_" + language]}) + "\" data-domain=\""+data+"\">" +
link_text +
"</a>";
}
Expand Down
6 changes: 6 additions & 0 deletions track/static/js/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ var Tables = {
Utils.updatePagination();
});

table.on("page.dt",function(){
/* scroll page to top of table on page change */
var top = $(".dataTable").offset().top;
$("html, body").animate({ scrollTop: top }, "slow");
});

return table;
},

Expand Down
44 changes: 23 additions & 21 deletions track/templates/en/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,34 @@

<section id="main-content" class="flex-1 bg-https-light-gray py-6">

<div class="flex flex-col lg:flex-row mx-auto items-center sm:w-4/5 xl:w-3/5">
<div class="flex-1 lg:mr-8 lg:pr-8 mb-4 lg:mb-0">
<h1 class="text-4xl sm:text-5xl mb-6">Track web security compliance</h1>
<h2 class="text-3xl mb-2">Making government websites more secure</h2>
<p class="text-xl">Canadians rely on the Government of Canada to provide secure digital services. A <a class="text-https-blue hover:text-black"
href="https://www.canada.ca/en/treasury-board-secretariat/services/information-technology/policy-implementation-notices/implementing-https-secure-web-connections-itpin.html">new
policy notice</a> guides government websites to adopt good web security practices. Track how government sites are
becoming more secure.</p>

<div class="flex">
<p class="text-xl mt-2 lg:mt-6"><a href="/en/domains/" class="text-https-blue hover:text-black">Check a government
website</a></p>
<object class="ml-2 lg:mt-4" type="image/svg+xml" tabindex="-1" aria-hidden="true" role="none" data="/static/images/cta-arrow.svg"></object>
</div>
<div class="flex flex-col lg:flex-row mx-auto items-center sm:w-4/5 xl:w-3/5">
<div class="flex-1 lg:mr-8 lg:pr-8 mb-4 lg:mb-0">
<h1 class="text-4xl sm:text-5xl mb-6">Track web security compliance</h1>
<h2 class="text-3xl mb-2">Making government websites more secure</h2>
<p class="text-xl">Canadians rely on the Government of Canada to provide secure digital services. A <a class="text-https-blue hover:text-black" href="https://www.canada.ca/en/treasury-board-secretariat/services/information-technology/policy-implementation-notices/implementing-https-secure-web-connections-itpin.html">new policy notice</a> guides government websites to adopt good web security practices. Track how government sites are becoming more secure.</p>

</div>
{% if request.headers.get("app-type","internal") == "internal" %}

<div class="flex">
<p class="text-xl mt-2 lg:mt-6"><a href="/en/domains/" class="text-https-blue hover:text-black">Check a government website</a></p>
<object class="ml-2 lg:mt-4" type="image/svg+xml" tabindex="-1" aria-hidden="true" role="none" data="/static/images/cta-arrow.svg"></object>
</div>

{% endif %}

<div class="flex-inline flex-col text-center mx-auto">
<div class="compliant"></div>
<h3 style="display:none" class="domains-text font-bold text-xl sm:text-2xl">Domains that <br> enforce HTTPS</h3>
</div>

<div class="flex-inline flex-col text-center mx-auto">
<div class="compliant"></div>
<h3 class="font-bold text-xl sm:text-2xl">Domains that <br> enforce HTTPS</h3>
</div>
</div>
</div>

</section>

{% include 'includes/donut.html' %}



<script src="/static/js/https/donuts.js?{{ now() | date("%Y%m%j%H%M%S") }}"></script>
<script src="/static/js/https/organizations.js?{{ now() | date("%Y%m%j%H%M%S") }}"></script>
{% endblock %}
{% endblock %}
17 changes: 14 additions & 3 deletions track/templates/en/layout-en.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
<head>

<title>{% block title %}{% endblock title %}</title>

{% include 'includes/head.html' %}

<meta name="description" content="{% block description %}{% endblock description %}">

</head>

<body class="flex flex-1 flex-col min-h-screen">

{% set GTM_key = "GOOGLE_TAG_MANAGER" | fetch_env() %}
{% if GTM_key %}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ GTM_key }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{% endif %}
<header role="banner" id="header">

<!-- Beta bar -->
Expand Down Expand Up @@ -40,7 +46,7 @@ <h2 class="sr-only">Language selection</h2>


<!-- Navigation -->

{% if request.headers.get("app-type","internal") == "internal" %}
<nav class="bg-white border-b border-https-dark-gray">
<div class="container mx-auto flex">
<div class="{{ self.pageid_fr() | site_title(false) }}">
Expand All @@ -64,6 +70,9 @@ <h2 class="py-6 text-base sm:text-lg hidden md:block"><a class="text-grey-darkes
</div>
</div>
</nav>
{% endif %}



<nav id="menu-content" class="shadow-md">
<ul class="list-reset ml-4 mr-2 mt-4 font-normal">
Expand All @@ -75,6 +84,8 @@ <h2 class="py-6 text-base sm:text-lg hidden md:block"><a class="text-grey-darkes
</ul>
</nav>



</header>

<main class="flex flex-auto">
Expand Down
5 changes: 3 additions & 2 deletions track/templates/fr/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ <h1 class="text-4xl sm:text-5xl mb-6">Suivre la conformité en matière de sécu
<h2 class="text-3xl mb-2">Rendre les sites gouvernementaux plus sécuritaires</h2>
<p class="text-xl">Les Canadiens s'attendent à ce que le gouvernement du Canada leur offre des services en ligne sécurisés. Un <a class="text-https-blue hover:text-black " href="https://www.canada.ca/fr/secretariat-conseil-tresor/services/technologie-information/avis-mise-oeuvre-politique/mise-oeuvre-https-connexions-web-securisees-ampti.html">nouvel avis de politique</a> vise à assurer que les sites gouvernementaux soient conformes aux bonnes pratiques en matière de sécurité Web. Voyez comment les sites gouvernementaux deviennent plus sécuritaires.</p>

{% if request.headers.get("app-type","public") == "internal" %}
<div class="flex">
<p class="text-xl mt-2 lg:mt-6"><a href="/fr/domaines/" class="text-https-blue hover:text-black ">Vérifier la conformité d’un site gouvernemental</a></p>
<object class="ml-2 lg:mt-4" type="image/svg+xml" tabindex="-1" role="img" aria-hidden="true" data="/static/images/cta-arrow.svg"></object>
</div>
{% endif %}

</div>

Expand All @@ -31,7 +33,6 @@ <h3 class=" text-xl sm:text-2xl">Domaines qui excécutent <br> le protocole HTT

</section>

{% include 'includes/donut.html' %}

<script src="/static/js/https/donuts.js?{{ now() | date("%Y%m%j%H%M%S") }}"></script>
<script src="/static/js/https/organizations.js?{{ now() | date("%Y%m%j%H%M%S") }}"></script>
{% endblock %}
11 changes: 9 additions & 2 deletions track/templates/fr/layout-fr.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
</head>

<body class="flex flex-1 flex-col min-h-screen">
{% set GTM_key = "GOOGLE_TAG_MANAGER" | fetch_env() %}
{% if GTM_key %}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ GTM_key }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{% endif %}

<header role="banner" id="header">

Expand All @@ -38,7 +45,7 @@ <h2 class="sr-only">Sélection de la langue</h2>
</section>

<!-- Navigation -->

{% if request.headers.get("app-type","internal") == "internal" %}
<nav class="bg-white border-b border-https-dark-gray">
<div class="container mx-auto flex">
<div class="{{ self.pageid_en() | site_title(false) }} flex-none">
Expand All @@ -62,7 +69,7 @@ <h2 class="mr-8 py-6 text-base sm:text-lg hidden md:block"><a class="text-grey-d
</div>
</div>
</nav>

{% endif %}
<nav id="menu-content" class="shadow-md">
<ul class="list-reset ml-4 mr-2 mt-4">
<li class="{{ self.pageid_en() | site_title(true) }} block py-4 border-b border-https-dark-gray sm:block md:hidden"><a tabindex="-1" class="text-xl text-https-blue no-underline hover:underline" href="/fr/index/">Suivre la conformité en matière de sécurité Web</a></li>
Expand Down
9 changes: 8 additions & 1 deletion track/templates/includes/en/beta-bar.html
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<div class="bg-grey-darkest py-1 text-xs sm:block md:block lg:block xl:block"></div>
<section class="bg-grey-darkest py-4 text-xs sm:block md:block lg:block xl:block">
<div class="container mx-auto text-white flex items-center">
<span class="flex-initial">
<span class="beta-badge py-2 px-2 font-bold rounded uppercase mr-4">Beta</span>
</span>
<span class="flex-1">This is a new service, we are constantly improving.</span>
</div>
</section>
Loading