Giter Site home page Giter Site logo

notaryproject / notation-go Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 41.0 3.87 MB

A collection of libraries for supporting sign and verify OCI artifacts. Based on Notary Project specifications.

License: Apache License 2.0

Go 99.74% Makefile 0.26%

notation-go's Introduction

Notary Project Specifications

This repository is in active maintenance and contains specifications shared across repositories under Notary Project as well as used by other open source projects and/or vendor tools that want to interoperate with Notary Project tooling.

Please see the Notary Project README file to learn about overall Notary Project.

In this README

Folder Structure

Folder Name Description
media Media files referenced by documents in this repository
requirements Requirements for Notary Project
security Notary Project security related documents and reports
specs Notary Project specifications
status-updates This folder is not in active maintenance and contains status updates report for Notary Project
threatmodels Threat models for repositories under Notary Project

Requirements

File Name Description
definitions-terms.md A collection of definitions and terms used within this repository
key-revocation.md Requirements and proposals for key revocation
keymanagementrequirements.md Requirements for key management
requirements.md A collection of requirements and scenarios for Notary Project
scenarios.md Notary Project signing scenarios
verification-by-reference.md Requirement of verification by reference

Security Documents

File Name Description
ADA-notation-security-audit-23.pdf Security audit report in 2023 covering notation, notation-go, and notation-core-go repositories
ADA-fuzzing-audit-22-23.pdf Fuzz testing audit in 2023 covering notary, notation-go, and notation-core-go repositories

Specifications

File Name Description
plugin-extensibility.md Notation Plugin specification
signature-envelope-cose.md Notary Project OCI COSE signature envelope
signature-envelope-jws.md Notary Project OCI JWS signature envelope
signature-specification.md Notary Project OCI signature specification
signing-and-verification-workflow.md Notary Project OCI signing and verification workflow
signing-scheme.md Notary Project signing scheme
trust-store-trust-policy.md Notary Project Trust Store and Trust Policy

Threat Models

File Name Description
notation-threatmodel.md Threat models for Notation CLI

Community

If you have any questions about Notary Project or contributing, do not hesitate to file an issue on relevant repository or contact the Notary Project maintainers and community members via the following channels:

notation-go's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notation-go's Issues

Implement Semantic Versioning

Notary V2 uses SemVer for plugin versioning. See spec here
At the time of writing this issue, Golang has no standard library support for parsing or comparing SemVer strings. This issue is to track implementing SemVer in Notation if no alternative is available. This issue is blocking using verification plugin minimum version critical attribute in signature verification workflow.

code:

// TODO verify the plugin's version is equal to or greater than `outcome.SignerInfo.SignedAttributes.HeaderVerificationPluginMinVersion`
// https://github.com/notaryproject/notation-go/issues/102

Notation plug-in design / notation-go-lib integration

Issue #22 surfaced an interesting question.
When using Notary v2 from a cli, we direct users to the notation repo and output
When using Notary v2 as a library, for use in other clis, how do we enable the notation plug-ins for specific key vault providers?

The current design enables users to install the notation cli and their desired plug-ins.
If someone uses the notation-go-lib to incorporate an SBoM signing solution, or some other integration, should they have to implement all the plug-in redirection?

Can we create an easy experience for developers to reference the notation-go-lib, and still get normal plug-in capabilities?

Release v0.8.0-alpha

Since the library has been renamed to notation-go and there are other breaking changes, we need to have a new release of notary at a minimum to make golang package references work well.

/cc @SteveLasker, @justincormack, @sajayantony

Can the maintainers please respond with a +1 comment once you are in favor of cutting this release.

Tracking issue for pending feedbacks/Issues in PR5

Tracking issue for multiple comments/issues that were called out in #5 and needs to be resolved.

Issues marked with [Alpha], must to be resolved for alpha release.

Security

Package Hygiene

Readability & Maintainability

  • [Alpha] For better readability, we should to add documentation for important packages and exported names.
  • [Alpha] Add unit tests. At minimum we need test which exercises positive scenario(successful signing and verification) to avoid breaking changes.

Signature(JWS)

Plugin not compliant error with test signature generation plugin

Iโ€™m creating a test plugin that supports signature generation, however am getting this error:

2022/06/06 00:17:51 generate-signature command failed: test-csp: failed to decode json response: plugin not compliant

Seems like it is having an issue with unmarshaling the plugin.GenerateSignatureResponse interface. If I unmarshal similar to where I believe the error is happening within the plugin there is no problem.

err = json.Unmarshal(out, resp)
if err != nil {
return nil, fmt.Errorf("failed to decode json response: %w", ErrNotCompliant)
}

plugin.GenerateSignatureRes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VGVL7kqcq7SG6iCaUyX7xsG5fMBMGrNSbENwMDOuQwKgCL"]}

Verify JWS header content

The content of JWS header is not verified including the cty and crit fields.
We need to verify those fields in case we have different types of payload.

Using Verifier without a repository

Hello Notation Maintainers,

We have been using notation-go v0.8.0-alpha.1 for notaryv2 signature validation in the ratify project. As part of ratify-project/ratify#274 we have been looking at updating to notation-go v0.10.0-alpha.3 to take advantage of some of the added trust store features, but have run into some challenges with integrating the new Verifier type.

In ratify we have a core executor that performs artifact verification for a provided subject by collecting artifact references from stores and verifying them with the appropriate verifiers. This means that when we call a verifier we have already retrieved the associated artifact from the registry. In our existing notaryv2 verifier implementation we use the Verify function and pass the signature, but in the new Verify function the verifier expects to retrieve all of the references itself and verify all of them in one call. Would it be possible to expose some of the functionality in the new Verifier type to operate on pre-fetched signatures?

I took a look at the Verify implementation it looks like it would fit our use case to call processSignature directly. Ideally we would like to use the Verifier without having to provide a repository since our execution model separates repositories and verifiers. Do you have any suggestions or concerns with this approach?

Thanks!

@shizhMSFT @binbin-li @dtzar

directory structure needs to isolate `read` and `write` path

As current design, when system level directory has the config file while user level directory doesn't have the config file, it uses the system level config file for read and write.

It is necessary to allow the user to know that whether the write path is user level or system level, so we need to:

  1. isolate read /write path
  2. provide the ability to select user/system level directory to write.
    Linked to System vs User file/directory precedence#203

Some unit tests fail on Windows platforms

Some unit tests in store_test.go fail on Windows platforms, and the error message is like below:

--- FAIL: TestLoadTrustStoreWithSymlinks (0.01s)
store_test.go:28: symlinks should return error : "Error while reading certificates from "testdata\\trust-store\\trust-store-with-cert-symlinks\\GlobalSignRootCA_SYMLINK.crt". Error : "x509: malformed certificate""
--- FAIL: TestLoadTrustStoreWithDirs (0.00s)
store_test.go:35: sub directories should return error : ""testdata\\trust-store\\trust-store-with-directories\\sub-dir" is not a regular file (directories or symlinks are not supported)"
--- FAIL: TestLoadTrustStoreWithInvalidCerts (0.00s)
store_test.go:42: invalid certs should return error : %!q()
--- FAIL: TestLoadTrustStoreWithLeafCerts (0.01s)
store_test.go:49: leaf cert in a trust store should return error : "certificate with subject "CN=lol,OU=lol,O=lol,L=lol,ST=Some-State,C=AU,1.2.840.113549.1.9.1=#13036c6f6c" from file "testdata\\trust-store\\trust-store-with-leaf-certs\\non-ca.crt" is not a CA certificate, only CA certificates (BasicConstraint CA=True) are allowed"
FAIL
FAIL github.com/notaryproject/notation-go/verification 4.042s
FAIL

It's because these test functions check the returned error by comparing its error message with a hard-coded error string, but the returned error message contains a Windows-style path which does not match the hard-coded path (See TestLoadTrustStoreWithInvalidCerts).

Tracks multiple TODOs in signature package

  • include external signing plugin's name and version in signing agent.
  • Verify plugin didnot add any additional top level payload attributes.
  • Add tests for this method. NewSignerFromFiles

#77

The associated Linked PullRequest - #178

Add more validations for timestamp response

We do need to add more validation for timestamp response to avoid MitM, replay, etc. attacks and also to be a compliant client. The validations are more from timestamp security and correctness perspective. If the timestamp signature is bad then it is of no use for users.

Haven't gone through complete rfc3161 but here are some notable mentions:

Originally posted by @priteshbandi in #11 (comment)

Reenable timestamping for signing and verification

As part of #77(Refactor to use notation-core-go's SignatureEnvelope), we disabled time-stamping support for signing and verification workflows.

Action Required:

  1. Implement timestamping support in notation-core-go.
  2. Enable timestamping support for signing and verification workflows in notation-go.
  3. Review verify TSA code which includes CMS parsing and verification. This code was included in alpha.1 and did not get through enough code review.
  4. Ensure adequate test coverage in notation-core-go for CMS parsing and verification.

Update Golang packages to proper names

The golang packages should match the URL of the repository as well as the released tagged versions available in GitHub.

https://pkg.go.dev/github.com/notaryproject/[email protected]?tab=importedby
Have dependencies on the repository. 1.0.0-alpha-1 doesn't exist as a release in the GitHub repository.

These two PRs will help fix a couple of the dependencies once there is a new release of notation-go and the packages are published.
notaryproject/notation#164
Azure/notation-azure-kv#16

Dependency on go-ldap

We are using go-ldap for parsing Distinguished Names (DN) of a trust policy's trustedIdentities field. Although we are using a single function from this library, this dependency is bringing bunch of additional dependencies unrelated to what notation does. We can remove the dependency and just copy the code that we need. But, we need to figure out a way to give attribution to go-ldap. Also, if we remove the dependency, we need to have a mechanism to pull the relevant updates, security patches periodically. This issue is to track how we are going to proceed with this dependency as we approach RC1 launch.

Allow timestamping to be per signature configuration.

One signer implementation(like file-based one) can be reused by multiple organization. Some organizations might not want to timestamp signature because of availability concerns or something else but other might prefer to timestamp signature.
So there should be a way to for user to disable/enable time-stamping on per signature basis. One way to achieve is that only add timestamp when user explicitly specifies it

  • notation sign --timestamp=${serverURL} <-- signs and timestamps
  • notation sign <-- only signs

Originally posted by @priteshbandi in #11 (comment)

API Testing

Summary
Automated Test Cases to be executed before every release for all APIs
Intended Outcome
A test suite is created over time and added iteratively over the lifetime of this project development
Additional context
The unit testing will be included in RC-1. The community met on 5/26 and made the decision to split this work as unit and end to end testing.

Release notation-go-lib-v0.7.0-alpha.1

Proposing we release notation-go-lib-v0.7.0-alpha.1 as we have completed the milestone. Release process is defined here.

High level deliverables as as follows:

  • Decide on main commit for release
  • Cut branch named v0.7.0-alpha.1 based on agreed upon main commit
  • Cut a tag named v0.7.0-alpha.1
  • Update README.md

/cc @SteveLasker @NiazFK @justincormack @sajayantony

Can the maintainers please respond with a +1 comment once you are in favor of cutting this release.

Add unit tests to the registry submodule

What?

As we moved registry from the notation to notation-go #63, unit tests are still missing for now. We need to add necessary tests to avoid breaking changes in the future.

Run symlink unit tests on Windows

Currently, Trust Store unit tests are skipping symlink tests on Windows as Windows requires Admin permissions to create Symlinks (see this). This issue is to identify a way to run symlink tests on Windows. More context : #58

Dont allow signer-provider or verification-provider to override the TSAVerifyOptions.

We don't want signer-provider or verification-provider to override the TSAVerifyOptions because then user can override this value and start using non time-stamping cert(like ssl) for time-stamping.

Also as per rfc3161#section-2.3
The corresponding certificate MUST contain only one instance of the extended key usage field extension as defined in [RFC2459] Section 4.2.1.13 with KeyPurposeID having value: id-kp-timeStamping.

I would suggest to start with not exposing TSAVerifyOptions and then later if need arises we can expose this option with sane defaults.

Originally posted by @priteshbandi in #15 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.