This repository has been archived by the owner on Jun 1, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename to reflect basic classifications
- Loading branch information
Showing
2 changed files
with
38 additions
and
49 deletions.
There are no files selected for viewing
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,38 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
read -d '' classifyExpandedParts <<-'EOF' || true | ||
def isSameDomain(domain): | ||
domain as $domain | ||
| . == $domain; | ||
def isSubdomain(domain): | ||
domain as $domain | ||
| endswith("." + $domain); | ||
def isSecure: | ||
. == "https"; | ||
def classifyUrl(origin): | ||
origin as $origin | ||
| { | ||
isSameDomain: (.domain | isSameDomain($origin.domain)), | ||
isSubdomain: (.domain | isSubdomain($origin.domain)), | ||
isSecure: (.protocol | isSecure) | ||
}; | ||
def mangle(origin): | ||
origin as $origin | ||
| .url as $urlParts | ||
| . + { | ||
classification : $urlParts | classifyUrl($origin) | ||
}; | ||
.origin.url as $origin | ||
| { | ||
origin: .origin | mangle($origin), | ||
requestedUrls: .requestedUrls | map(mangle(($origin))) | ||
} | ||
EOF | ||
|
||
cat | jq "$classifyExpandedParts" |