Skip to content

Commit

Permalink
Merge pull request #1 from brave/master
Browse files Browse the repository at this point in the history
Rebase
  • Loading branch information
Akarshan Biswas authored Aug 21, 2019
2 parents 82c1d5f + 61cb4d8 commit fd02cf3
Show file tree
Hide file tree
Showing 33 changed files with 7,426 additions and 626 deletions.
17 changes: 12 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@ INSUFFICIENT INFO WILL GET THE ISSUE CLOSED. IT WILL ONLY BE REOPENED AFTER SUFF
<!--For installed build, please copy Brave, Revision and OS from brave://version and paste here. If building from source please mention it along with brave://version details-->


### Reproducible on current release:
- Does it reproduce on brave-browser dev/beta builds?
## Version/Channel Information:
<!--Does this issue happen on any other channels? Or is it specific to a certain channel?-->

### Website problems only:
- Does the issue resolve itself when disabling Brave Shields?
- Can you reproduce this issue with the current release?
- Can you reproduce this issue with the beta channel?
- Can you reproduce this issue with the dev channel?
- Can you reproduce this issue with the nightly channel?

## Other Additional Information:

- Does the issue resolve itself when disabling Brave Shields?
- Does the issue resolve itself when disabling Brave Rewards?
- Is the issue reproducible on the latest version of Chrome?

### Additional Information
## Miscellaneous Information:
<!--Any additional information, related issues, extra QA steps, configuration or data that might be necessary to reproduce the issue-->
24 changes: 20 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
- [ ] Used Github [auto-closing keywords](https://help.github.com/articles/closing-issues-via-commit-messages/) in the commit message.
- [ ] Added/updated tests for this change (for new code or code which already has tests).
- Verified that these changes build without errors on
- [ ] Windows
- [ ] macOS
- [ ] Android
- [ ] iOS
- [ ] Linux
- Verified that these changes pass automated tests (`npm test brave_unit_tests && npm test brave_browser_tests && npm run test-security`) on
- [ ] Windows
- [ ] macOS
- [ ] Windows
- Verified that these changes pass automated tests (unit, browser, security tests) on
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Windows
- [ ] Ran `git rebase master` (if needed).
- [ ] Ran `git rebase -i` to squash commits (if needed).
- [ ] Tagged reviewers and labelled the pull request as needed.
- [ ] Requested a security/privacy review as needed.
- [ ] Public documentation has been updated as necessary. For instance:
- [ ] https://github.com/brave/brave-browser/wiki/Deviations-from-Chromium-(features-we-disable-or-remove)
- [ ] https://github.com/brave/brave-browser/wiki/Proxy-redirected-URLs
- [ ] https://github.com/brave/brave-browser/wiki/Fingerprinting-Protection-Mode
- [ ] https://github.com/brave/brave-browser/wiki/Brave%E2%80%99s-Use-of-Referral-Codes
- [ ] https://github.com/brave/brave-browser/wiki/Custom-Headers
- [ ] https://github.com/brave/brave-browser/wiki/Web-compatibility-issues-with-tracking-protection

## Test Plan:

Expand All @@ -24,3 +34,9 @@
- [ ] New files have MPL-2.0 license header.
- [ ] Request a security/privacy review as needed.
- [ ] Adequate test coverage exists to prevent regressions.

## After-merge Checklist:

- [ ] The associated issue milestone is set to the smallest version that the
changes has landed on.
- [ ] All relevant documentation has been updated.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ src
npm-debug.log
.gclient
.sccache
**.sw[po]
*.sw[po]
.vscode
.cipd
.idea
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "vendor/jinja"]
path = vendor/jinja
url = git://github.com/pallets/jinja.git
[submodule "vendor/gn-project-generators"]
path = vendor/gn-project-generators
url = git://github.com/brave/gn-project-generators
214 changes: 194 additions & 20 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1,067 changes: 697 additions & 370 deletions Jenkinsfile

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ For other versions of our browser, please see:

## Community

[Join the Q&A community](https://community.brave.com/) if you'd like to get more involved with Brave. You can [ask for help](https://community.brave.com/c/help-me),
[discuss features you'd like to see](https://community.brave.com/c/feature-requests), and a lot more. We'd love to have your help so that we can continue improving Brave.
[Join the Q&A community](https://community.brave.com/) if you'd like to get more involved with Brave. You can [ask for help](https://community.brave.com/c/support-and-troubleshooting),
[discuss features you'd like to see](https://community.brave.com/c/brave-feature-requests), and a lot more. We'd love to have your help so that we can continue improving Brave.

Help us translate Brave to your language by submitting translations at https://www.transifex.com/brave/brave/

Expand Down
9 changes: 9 additions & 0 deletions SECURITY.md
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.
49 changes: 35 additions & 14 deletions docs/source/installing-brave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ NOTE: If Brave does not start and shows an error about sandboxing, you may need
to enable `user namespaces
<https://superuser.com/questions/1094597/enable-user-namespaces-in-debian-kernel#1122977>`_. For security reasons, we do NOT recommend running with the ``--no-sandbox`` flag. For more info, see https://github.com/brave/brave-browser/issues/1986#issuecomment-445057361.

NOTE: While we recommend you to use our official packages, there's a section for unofficial package in the case where we don't ship packages for your distribution. These packages are community maintained, and therefore we take no responsibility for them.

Release Channel Installation
============================

Expand All @@ -19,6 +17,8 @@ Ubuntu 16.04+ and Mint 18+
--------------------------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add -

source /etc/os-release
Expand All @@ -27,19 +27,26 @@ Ubuntu 16.04+ and Mint 18+

sudo apt update

sudo apt install brave-keyring brave-browser
sudo apt install brave-browser

Debian 9, Ubuntu 14.04 and Mint 17
----------------------------------

If you get ``gnutls_handshake()`` errors after adding the Brave repository on Debian 9,
you may need to `uninstall old conflicting packages
<https://github.com/signalapp/Signal-Desktop/issues/2483#issuecomment-401047201>`_.

Mint 17
-------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add -

echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ trusty main" | sudo tee /etc/apt/sources.list.d/brave-browser-release-trusty.list

sudo apt update

sudo apt install brave-keyring brave-browser
sudo apt install brave-browser

Fedora 28+
----------
Expand All @@ -49,7 +56,7 @@ Fedora 28+

sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc

sudo dnf install brave-keyring brave-browser
sudo dnf install brave-browser

CentOS/RHEL
-----------
Expand All @@ -64,7 +71,7 @@ CentOS/RHEL
enabled=1
EOF

sudo yum install brave-keyring brave-browser
sudo yum install brave-browser

The key you're importing should have fingerprint ``D8BA D4DE 7EE1 7AF5 2A83 4B2D 0BB7 5829 C2D4 E821``.

Expand All @@ -78,6 +85,8 @@ Ubuntu 16.04+ and Mint 18+
--------------------------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-beta.s3.brave.com/brave-core-nightly.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-beta.gpg add -

source /etc/os-release
Expand All @@ -88,10 +97,12 @@ Ubuntu 16.04+ and Mint 18+

sudo apt install brave-browser-beta

Mint 17
-------
Debian 9, Ubuntu 14.04 and Mint 17
----------------------------------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-beta.s3.brave.com/brave-core-nightly.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-beta.gpg add -

echo "deb [arch=amd64] https://brave-browser-apt-beta.s3.brave.com/ trusty main" | sudo tee /etc/apt/sources.list.d/brave-browser-beta-trusty.list
Expand Down Expand Up @@ -137,6 +148,8 @@ Ubuntu 16.04+ and Mint 18+
--------------------------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-dev.s3.brave.com/brave-core-nightly.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-dev.gpg add -

source /etc/os-release
Expand All @@ -147,10 +160,12 @@ Ubuntu 16.04+ and Mint 18+

sudo apt install brave-browser-dev

Mint 17
-------
Debian 9, Ubuntu 14.04 and Mint 17
----------------------------------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-dev.s3.brave.com/brave-core-nightly.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-dev.gpg add -

echo "deb [arch=amd64] https://brave-browser-apt-dev.s3.brave.com/ trusty main" | sudo tee /etc/apt/sources.list.d/brave-browser-dev-trusty.list
Expand Down Expand Up @@ -196,6 +211,8 @@ Ubuntu 16.04+ and Mint 18+
--------------------------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-nightly.s3.brave.com/brave-core-nightly.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-nightly.gpg add -

source /etc/os-release
Expand All @@ -206,10 +223,12 @@ Ubuntu 16.04+ and Mint 18+

sudo apt install brave-browser-nightly

Mint 17
-------
Debian 9, Ubuntu 14.04 and Mint 17
----------------------------------
::

sudo apt install apt-transport-https curl

curl -s https://brave-browser-apt-nightly.s3.brave.com/brave-core-nightly.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-nightly.gpg add -

echo "deb [arch=amd64] https://brave-browser-apt-nightly.s3.brave.com/ trusty main" | sudo tee /etc/apt/sources.list.d/brave-browser-nightly-trusty.list
Expand Down Expand Up @@ -249,6 +268,8 @@ The key you're importing should have fingerprint ``9228 DBCE 20DD E5EC 4648 8DE
Unofficial packages
============================

NOTE: While we recommend you to use our official packages, there's a section for unofficial package in the case where we don't ship packages for your distribution. These packages are community maintained, and therefore we take no responsibility for them.

.. highlight:: console

Solus
Expand Down
14 changes: 14 additions & 0 deletions jest.config.js
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"
}
25 changes: 19 additions & 6 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ const checkVersionsMatch = () => {
const found = versionData.match(re)
const braveVersionFromChromeFile = `${found[2]}.${found[3]}.${found[4]}`
if (braveVersionFromChromeFile !== config.braveVersion) {
// Only a warning. The CI environment will choose to proceed or not within its own script.
console.warn(`Version files do not match!\nsrc/chrome/VERSION: ${braveVersionFromChromeFile}\nbrave-browser package.json version: ${config.braveVersion}`)
if (config.buildConfig === 'Release') {
process.exit(1)
}
}
}

Expand All @@ -96,9 +94,24 @@ const build = (buildConfig = config.defaultBuildConfig, options) => {
touchOverriddenVectorIconFiles()
util.updateBranding()

util.buildTarget()
if (config.shouldSign()) {
util.signApp()
if (config.xcode_gen_target) {
util.generateXcodeWorkspace()
} else {
util.buildTarget()
if (config.shouldSign()) {
util.signApp()
}

if (process.platform === 'win32') {
// Sign only binaries for widevine sig generation.
// Other binaries will be done during the create_dist.
// Then, both are merged whenarchive for installer is created.
util.signWinBinaries()

if (config.brave_enable_cdm_host_verification) {
util.generateWidevineSigFiles()
}
}
}
}

Expand Down
28 changes: 28 additions & 0 deletions lib/calculateFileChecksum.js
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);
}
});
}
45 changes: 45 additions & 0 deletions lib/calculateFileChecksum.test.js
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)
})
Loading

0 comments on commit fd02cf3

Please sign in to comment.