Skip to content

Commit

Permalink
add audit log path to reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Webb authored and Kevin Webb committed Dec 1, 2020
1 parent 8615e70 commit d545e7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/report.js
Expand Up @@ -60,16 +60,18 @@ async function report(
const reportPath = path.join(reportsPath, reportDay, provider + ".html");
const metricsPath = path.join(dataPath, provider + ".json");
const metrics = fs.readFileSync(metricsPath).toString();
const metricsData = JSON.parse(metrics);

const signature = crypto
.createHmac("sha256", version)
.createHmac("sha256", metricsData.version)
.update(metrics)
.digest("hex");

var html = report;
html = html.split("$provider$").join(provider);
html = html.split("$data$").join(metrics);
html = html.split("$signature$").join(signature);
html = html.split("$signature$").join(metricsData.version + ": " + signature);
html = html.split("$auditPath$").join(metricsData.auditPath);

fs.writeFileSync(reportPath, html);
}
Expand Down
3 changes: 1 addition & 2 deletions src/summarize.js
Expand Up @@ -87,6 +87,7 @@ const summarize = async function(

var stats = {
version: version,
auditPath: auditPath,
totalVehicles: 0,
totalActiveVehicles: 0,
totalTrips: 0,
Expand Down Expand Up @@ -241,8 +242,6 @@ const summarize = async function(
stats.averageTrips = stats.totalTrips / stats.totalActiveVehicles;
}

console.log(JSON.stringify(auditLog));

// build state histories for each vehicle
var states = {};
changes.forEach(change => {
Expand Down
1 change: 1 addition & 0 deletions templates/report.html
Expand Up @@ -542,6 +542,7 @@ <h2 class="subtitle is-4">Flows</h2>
<div id="sign" class="tile">
<div class="tile is-vertical is-12">
<h3 class="info has-text-grey">🔒 $signature$</h3>
<h3 class="info has-text-grey">Audit path: $auditPath$</h3>
</div>
</div>

Expand Down

0 comments on commit d545e7a

Please sign in to comment.