Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security SQL 2020: add 2019 results for security header adoption #1644

Merged
merged 1 commit into from
Dec 6, 2020
Merged
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion sql/2020/11_Security/security_headers_prevalence.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,30 @@ CREATE TEMPORARY FUNCTION hasHeader(headers STRING, headername STRING)
''';

SELECT
date,
client,
headername,
COUNT(DISTINCT host) AS total_hosts,
COUNT(DISTINCT IF(hasHeader(headers, headername), host, NULL)) AS num_with_header,
COUNT(DISTINCT IF(hasHeader(headers, headername), host, NULL)) / COUNT(DISTINCT host) AS pct_with_header
FROM (
SELECT
date,
client,
NET.HOST(urlShort) AS host,
JSON_EXTRACT(payload, '$.response.headers') AS headers
FROM
`httparchive.almanac.requests`
WHERE
date = "2020-08-01" AND
(date = "2020-08-01" OR date = "2019-07-01") AND
NET.HOST(urlShort) = NET.HOST(page)
),
UNNEST(['Content-Security-Policy', 'Cross-Origin-Embedder-Policy', 'Cross-Origin-Opener-Policy', 'Cross-Origin-Resource-Policy', 'Expect-CT', 'Feature-Policy', 'Permissions-Policy', 'Referrer-Policy', 'Report-To', 'Strict-Transport-Security', 'X-Content-Type-Options', 'X-Frame-Options', 'X-XSS-Protection']) AS headername
GROUP BY
date,
client,
headername
ORDER BY
date,
client,
headername