Commit 665d2f79 authored by Aral Balkan's avatar Aral Balkan
Browse files

Enhancement: inquiry supports local subset inquiries

Closes #35. When you specify the --local flag and a regexp
of CSV file paths, only the domains listed in those CSV files
will be used during the local inquiry.
parent 4c477552
......@@ -212,15 +212,28 @@ numberOfDomainsToAnalyse = 1000
#
prepareInspectionsForLocalInquiry = ->
fs.readdirAsync archivePath
.then (files) ->
domains = (files.filter (file) -> file not in ['.DS_Store', 'index.html']).map (file) -> file.replace '.har.gz', ''
inspections = domains.map (domain) -> return (-> inspect domain)
domainsToInspect = inspections.length
#
# If arguments exists, they must be file path regular expressions pointing
# to CSV files with the domains to inspect locally.
#
if (args._.length > 0)
# We can reuse the technique used in remote inspections.
console.log "*** Preparing local inspection for domains provided in CSV"
return prepareInspectionsForRemoteInquiry()
else
#
# Default behaviour when no commandline argument is supplied:
# the local inspection includes all domains in the archive directory.
#
fs.readdirAsync archivePath
.then (files) ->
domains = (files.filter (file) -> file not in ['.DS_Store', 'index.html']).map (file) -> file.replace '.har.gz', ''
inspections = domains.map (domain) -> return (-> inspect domain)
domainsToInspect = inspections.length
return inspections
.catch (error) ->
throw new Error "Could not prepare inspections for local inquiry: #{error}"
return inspections
.catch (error) ->
throw new Error "Could not prepare inspections for local inquiry: #{error}"
#
......@@ -250,6 +263,10 @@ getNormalisedDomains = ->
fs.readFileAsync (path.join domainsPath, domain), 'utf-8'
.then (domainList) ->
# Make lowercase.
domainList = domainList.toLowerCase()
# Split into lines.
domainListArray = (domainList.split "\n")
# If the last line has a newline, remove the empty last item.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment