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

Fix 738 log addon version #771

Merged
merged 7 commits into from
Sep 28, 2021
Merged

Fix 738 log addon version #771

merged 7 commits into from
Sep 28, 2021

Conversation

g-k
Copy link
Contributor

@g-k g-k commented Sep 22, 2021

fix #738

Changes:

  • rename test vars PASSINGTESTCASES to validSignerConfigs and FAILINGTESTCASES to invalidSignerConfigs to avoid confusion with other vars named testcases
  • use go embed directives (1.16+) https://pkg.go.dev/embed to remove bytestrings from source files and expose the files for other tools to inspect (e.g. unzip -l)
    • add .zip to the omni.ja files so zip tools recognize them as zips
  • test sign file against the ublock and omni.ja fixtures
  • run TestSign{Data,File} test cases in parallel saved ~6s on local testing of the package
  • log the addon manifest.json top-level version field and .browser_specific_settings.gecko.id field using

@coveralls
Copy link

coveralls commented Sep 22, 2021

Pull Request Test Coverage Report for Build 7222

  • 27 of 32 (84.38%) changed or added relevant lines in 1 file are covered.
  • 18 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.3%) to 71.212%

Changes Missing Coverage Covered Lines Changed/Added Lines %
signer/xpi/jar.go 27 32 84.38%
Files with Coverage Reduction New Missed Lines %
signer/xpi/xpi.go 5 80.0%
signer/xpi/x509.go 13 74.85%
Totals Coverage Status
Change from base Build 7212: -0.3%
Covered Lines: 3243
Relevant Lines: 4554

💛 - Coveralls

@g-k g-k requested a review from willdurand September 22, 2021 20:37
@g-k g-k marked this pull request as ready for review September 22, 2021 20:37
Gecko struct {
ID string `json:"id"`
} `json:"gecko"`
} `json:"browser_specific_settings"`
Copy link
Member

Choose a reason for hiding this comment

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

I think applications is an alias for browser_specific_settings. In addition, this prop is optional.

Is it OK to not log the add-on ID all the time?

Copy link
Member

Choose a reason for hiding this comment

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

Some more information:

  1. the version should be mandatory
  2. the GUID (same value as the Gecko ID) is somehow inserted in the signature of a signed XPI so I suppose there is a way to always get the GUI somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think applications is an alias for browser_specific_settings. In addition, this prop is optional.

TIL! I didn't see that key on MDN or in the webext spec, but these pages suggest Fx <48 required it:

so it probably predates standardization and we might have to sign addons with that key.

Is it OK to not log the add-on ID all the time?

Yes, I have a few test cases for partial matches and XPIs signed in other modes (privileged, hotfix, etc.) probably won't include the an ID or might use the other key.

8b4f491 adds test cases for:

  • a manifest with applications set to an empty obj
  • a manifest with applications.gecko set to an empty obj
  • a manifest with applications.gecko.id set to an empty str
  • a manifest with applications.gecko.id set to an addon ID
  • a manifest with a version and both IDs set (in which case we'll prefer the browser settings ID)

Once we have some logs, I'll try to confirm we can correlate them with signed addons. If not, we might need pass the data out to the "signing operation succeeded" lines.

Copy link
Contributor Author

@g-k g-k Sep 23, 2021

Choose a reason for hiding this comment

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

Some more information:

1. the `version` should be mandatory

Hmm, extractAddonIDAndVersionFromWebextManifest could return an error and we could log it as a warning instead of info level.

If other XPI types that don't include a manifest, we won't log warnings. If they do, we might log some extra warnings but that'd be fine.

2. the GUID (same value as the Gecko ID) is somehow inserted in the signature of a signed XPI so I suppose there is a way to _always_ get the GUI somewhere?

Does addons-server generate that and send it as Options.ID?

Copy link
Member

Choose a reason for hiding this comment

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

willdurand
willdurand previously approved these changes Sep 28, 2021
Copy link
Member

@willdurand willdurand left a comment

Choose a reason for hiding this comment

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

r+wc

},
{
name: "version with applications.gecko.id and browser_specific_settings.gecko.id both set in JSON prefers browser_specific_settings id",
manifestBytes: []byte("{\"applications\":{\"gecko\":{\"id\":\"[email protected]\"}},\"browser_specific_settings\":{\"gecko\":{\"id\":\"{5ae54d6f-bcb2-48ec-b98c-7a19e983283f}\"}},\"version\":\"1.2.3\"}"),
Copy link
Member

Choose a reason for hiding this comment

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

addons-linter won't accept a manifest with the two props but it's good to be defensive here.

@g-k g-k merged commit 48d6ea2 into main Sep 28, 2021
@g-k g-k deleted the fix-738-log-addon-version branch September 28, 2021 14:02
@g-k
Copy link
Contributor Author

g-k commented Sep 28, 2021

Thanks Will!

Follow up items from comments and original issue:

  • return parsed ID and version to SignFile in xpi
    • log parsed ID and version with the "signing operation succeeded" lines instead of from the repacking code
    • when signing in mode ModeAddOn and ModeAddOnWithRecommendation check the lints:
      • warn for a missing manifest.json file
      • warn for multiple IDs: applications.gecko.id and browser_specific_settings.gecko.id
      • warn for manifest ID not matching request Options.ID
      • warn for a missing version

Warnings return errors if we want to do more linting in autograph and other web extension signers pass for legitimate uses.

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.

log signed XPI or addon version number
3 participants