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

feat: deny list #174

Merged
merged 56 commits into from
Jul 28, 2021
Merged

feat: deny list #174

merged 56 commits into from
Jul 28, 2021

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Jul 14, 2021

Allow users to specify deny list rules for the construct hub. Rules can match a package name and optionally a specific version. If a package is matched against a rule, the package is ignored by the discovery function, its relevant objects are deleted from the package data bucket and the catalog is created.

new ConstructHub(this, 'ConstructHub', {
  denyList: [
    { package: '@aws-cdk/cdk', reason: 'This package has been deprecated in favor of @aws-cdk/core' },
    { package: 'cdk-foo-bar', version: '0.0.2', reason: 'Dummy package' },
  ],
});

Design

A deny-list.json file is created in a dedicated S3 bucket and contains a hash map from package (or package/vX.Y.Z) to the deny list rule. A DenyListClient is provided with a simple API for consuming the deny list.

The discovery function will skip any packages that match a deny list rule.

An AWS Lambda function called "Prune Handler" is triggered every time the deny list is updated and periodically every 5 minutes (to compensate for race conditions with the ingestion flow). The prune handler iterates over the deny list and lists all the S3 objects in the package data bucket that match the prefix. It queues the matched objects into an SQS queue.

The SQS queue is consumed by another handler called "Prune Delete Handler" which deletes pruned objects and also triggers the catalog builder function so that the catalog will be rebuilt as needed.

We have also added REMOVE_OBJECT notification to the cache invalidation handler to make sure deleted objects are reflected in the edge cache as soon as possible. This required changing the cache invalidation CallerReference to use the Lambda request ID instead of the object ID.

A section was added to the backend dashboard which monitors these resources.

Integration Tests

This commit also adds support for integration tests, which work similarly to AWS CDK integration tests. They are small CDK apps (with the xxx.integ.ts suffix) which can be deployed using yarn integ:xxx:deploy and if their deployment is successful, a snapshot is stored and compared against a synthesized result during tests. To implement integration test assertions, users can implement a trigger.xxx.lambda.ts handlers which can be added to the test app and executed during deployment (see README for more details).

Misc

  • Removed the explicit names for the watchful and high-severity dashboards so now they are automatically generated.
  • Remove the requirement to specify alarm actions for the monitoring system (to facilitate tests).
  • Added a button to access the S3 bucket and the catalog builder function to the "Catalog Overview" section in the backend dashboard.
  • Modified the catalog builder function to allow rebuilding the catalog by just invoking the function without an event.

Resolves https://github.com/cdklabs/construct-hub-internal/issues/34
Resolves #66


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Allow users to specify deny list rules for the construct hub. Rules can match a package name and optionally a specific version. If a package is matched against a rule, the package is ignored and a log entry is emitted with the reason information.
@eladb eladb marked this pull request as draft July 14, 2021 09:16
Elad Ben-Israel and others added 20 commits July 22, 2021 17:39
I forgot to grant permissions to read the Bucket and start
the State Machines executions... Oops.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Upgrades project dependencies. See details in [workflow run].

[Workflow Run]: https://github.com/cdklabs/construct-hub/actions/runs/1058031052

------

*Automatically created by projen via the "upgrade-dependencies" workflow*
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Co-authored-by: Automation <github-actions@github.com>
Upgrades project dependencies. See details in [workflow run].

[Workflow Run]: https://github.com/cdklabs/construct-hub/actions/runs/1061359517

------

*Automatically created by projen via the "upgrade-dependencies" workflow*
Upgrades project dependencies. See details in [workflow run].

[Workflow Run]: https://github.com/cdklabs/construct-hub/actions/runs/1063494650

------

*Automatically created by projen via the "upgrade-dependencies" workflow*
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@eladb eladb marked this pull request as ready for review July 26, 2021 12:35
Elad Ben-Israel and others added 2 commits July 26, 2021 15:46
.projenrc.js Outdated Show resolved Hide resolved
.projenrc.js Outdated Show resolved Hide resolved
API.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/backend/discovery/constants.lambda-shared.ts Outdated Show resolved Hide resolved
src/backend/discovery/discovery.lambda.ts Outdated Show resolved Hide resolved
src/backend/discovery/discovery.lambda.ts Outdated Show resolved Hide resolved
src/backend/discovery/discovery.lambda.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@RomainMuller RomainMuller left a comment

Choose a reason for hiding this comment

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

Approved as discussed - outstanding minor comments to be handled in a subsequent PR.

@mergify mergify bot merged commit 270fae7 into main Jul 28, 2021
@mergify mergify bot deleted the benisrae/deny-list branch July 28, 2021 10:34
mergify bot pushed a commit that referenced this pull request Jul 28, 2021
As a follow up of #174, we decided that we wanted the catalog builder to consult the deny list and avoid adding any packages to the catalog that match. This should be applied to full rebuilds as well as to incremental additions.

This change adds this behavior to the catalog builder (along with tests) and also changes the deny list prune component to trigger a catalog rebuild only once instead of per deletion.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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.

Implement package deny-list
3 participants