-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from brave/master
Rebase
- Loading branch information
Showing
33 changed files
with
7,426 additions
and
626 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ src | |
npm-debug.log | ||
.gclient | ||
.sccache | ||
**.sw[po] | ||
*.sw[po] | ||
.vscode | ||
.cipd | ||
.idea | ||
|
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
Large diffs are not rendered by default.
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 |
---|---|---|
|
@@ -19,9 +19,9 @@ RUN apt-get update && apt-get install -y \ | |
RUN npm install -g [email protected] | ||
RUN pip install Jinja2==2.8.1 | ||
|
||
RUN curl -sSf https://static.rust-lang.org/rustup.sh | sh | ||
RUN cargo install sccache | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
RUN cargo install sccache | ||
RUN echo "sccache = /root/.cargo/bin/sccache" > /root/.npmrc | ||
|
||
# BLB source code. Mount ./browser-laptop-bootstrap from the host to here. | ||
|
Large diffs are not rendered by default.
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
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,9 @@ | ||
# Security Policy | ||
|
||
## Supported Versions | ||
|
||
All versions including and above the current stable release version number (the version downloadable on https://brave.com/download). | ||
|
||
## Reporting a Vulnerability | ||
|
||
See https://hackerone.com/brave for details. |
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
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,14 @@ | ||
// For a detailed explanation regarding each configuration property, visit: | ||
// https://jestjs.io/docs/en/configuration.html | ||
|
||
module.exports = { | ||
clearMocks: true, | ||
roots: [ | ||
"lib", | ||
"scripts" | ||
], | ||
testPathIgnorePatterns: [ | ||
'lib/test.js' | ||
], | ||
testEnvironment: "node" | ||
} |
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
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,28 @@ | ||
// Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// you can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
const crypto = require('crypto') | ||
const fs = require('fs') | ||
|
||
module.exports = function CalculateFileChecksum(filePath, algorithm = 'sha256') { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
const checksumGenerator = crypto.createHash(algorithm); | ||
const fileStream = fs.createReadStream(filePath) | ||
fileStream.on('error', function (err) { | ||
err.message = `CalculateFileChecksum error in FileStream at path "${filePath}": ${err.message}` | ||
reject(err) | ||
}) | ||
checksumGenerator.once('readable', function () { | ||
const checksum = checksumGenerator.read().toString('hex') | ||
resolve(checksum) | ||
}) | ||
fileStream.pipe(checksumGenerator) | ||
} catch (err) { | ||
err.message = `CalculateFileChecksum error using algorithm "${algorithm}" at path "${filePath}": ${err.message}` | ||
reject(err); | ||
} | ||
}); | ||
} |
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,45 @@ | ||
const path = require('path') | ||
const fs = require('fs-extra') | ||
const os = require('os') | ||
const calculateFileChecksum = require('./calculateFileChecksum') | ||
|
||
const dirPrefixTmp = 'brave-browser-test-calculate-file-checksum-' | ||
const testFile1Name = 'file1' | ||
const testFile1InitialContent = 'this is a test' | ||
const encoding = 'utf8' | ||
let testDirPath, testFile1Path | ||
|
||
beforeEach(async function () { | ||
// Test directory | ||
testDirPath = await fs.mkdtemp(path.join(os.tmpdir(), dirPrefixTmp)) | ||
// Initial test file | ||
testFile1Path = path.join(testDirPath, testFile1Name) | ||
await fs.writeFile(testFile1Path, testFile1InitialContent, encoding) | ||
}) | ||
|
||
afterEach(async function () { | ||
// Remove test directory | ||
try { | ||
await fs.remove(testDirPath) | ||
} catch (err) { | ||
console.warn('Test cleanup: could not remove temp directory at ' + testDirPath) | ||
} | ||
}) | ||
|
||
test('generates a checksum', async function () { | ||
const checksum1 = await calculateFileChecksum(testFile1Path) | ||
expect(checksum1).toBeTruthy() | ||
}) | ||
|
||
test('checksum is stable', async function () { | ||
const checksum1 = await calculateFileChecksum(testFile1Path) | ||
const checksum2 = await calculateFileChecksum(testFile1Path) | ||
expect(checksum2).toBe(checksum1) | ||
}) | ||
|
||
test('checksum changes when file contents change', async function () { | ||
const checksum1 = await calculateFileChecksum(testFile1Path) | ||
await fs.writeFile(testFile1Path, testFile1InitialContent + testFile1InitialContent, encoding) | ||
const checksum2 = await calculateFileChecksum(testFile1Path) | ||
expect(checksum2).not.toBe(checksum1) | ||
}) |
Oops, something went wrong.