Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[extensions] Add a switch to generate a publisher proof #12090

Merged
merged 7 commits into from
Feb 10, 2022

Conversation

atuchin-m
Copy link
Collaborator

@atuchin-m atuchin-m commented Feb 1, 2022

Resolves brave/brave-browser#873

This PR adds ability to add a publisher proof during packing an extension or components. This will be used on CI during signing brave components.

How to use it :
brave.exe --pack-extension=.\test-extension --pack-extension-key=.\key.pem --brave-extension-publisher-key=.\publisher.pem
Return zero if all is good.

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@atuchin-m atuchin-m requested review from iefremov and goodov February 1, 2022 14:38
@atuchin-m atuchin-m requested review from a team as code owners February 1, 2022 14:38
@atuchin-m atuchin-m self-assigned this Feb 1, 2022
@atuchin-m atuchin-m force-pushed the add-switch-to-generate-publisher-proof branch 2 times, most recently from 0e5c058 to 52be4d9 Compare February 1, 2022 14:42
@atuchin-m atuchin-m force-pushed the add-switch-to-generate-publisher-proof branch from 52be4d9 to f2d5b58 Compare February 1, 2022 14:43
chromium_src/components/crx_file/crx_verifier.cc Outdated Show resolved Hide resolved
publisher_key = \
ReadInputKey(cmd->GetSwitchValuePath(kPublisherKeySwitch)); \
if (!publisher_key) \
return false; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to state the fact that error_message_ will be set by ReadInputKey in this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment.

#include "base/command_line.h"
#include "base/files/file_path.h"
#include "components/crx_file/crx_creator.h"
#include "components/crx_file/id_util.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

result = crx_file::CreateWithPublisherKey(output_path, zip_path, \
signing_key, publisher_key.get());

#include "src/extensions/browser/extension_creator.cc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#undef BRAVE_CREATE_CRX

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.


// Generate a publish key hash from .pem file in the format used in
// crx_verifier.cc.
std::vector<uint8_t> GetPublicKeyHash(const base::FilePath& pem_path) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put it into fixture or anonymous namespace.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

base::FilePath CreateTestCrx() {
base::ScopedAllowBlockingForTesting allow_blocking;

brave::RegisterPathProvider();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already done in the constructor

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

publisher_key = \
ReadInputKey(cmd->GetSwitchValuePath(kPublisherKeySwitch)); \
if (!publisher_key) \
return false; /* error_message_ was be set by ReadInputKey() */ \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was set

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@iefremov iefremov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diracdeltas @fmarier can take a quick look please?

chromium_src/components/crx_file/crx_creator.cc Outdated Show resolved Hide resolved
namespace extensions {

namespace {
// Generate a publish key hash from .pem file in the format used in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By publish key, do you mean a publisher key or a public key?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean a public key here: the function can fetch a public key and generate it's hash from any PEM file (not only is used for a publisher proof)

browser/extensions/brave_crx_generation_browsertest.cc Outdated Show resolved Hide resolved
@atuchin-m atuchin-m merged commit 094ba1f into master Feb 10, 2022
@atuchin-m atuchin-m deleted the add-switch-to-generate-publisher-proof branch February 10, 2022 17:30
@atuchin-m atuchin-m added this to the 1.37.x - Nightly milestone Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add publisher proof support for our CRX3 files
4 participants