From b3f650b1a8546f05779a2d43f8dc61a8658d136e Mon Sep 17 00:00:00 2001 From: Justin De Burgo Date: Mon, 6 Feb 2023 12:36:57 -0600 Subject: [PATCH 1/3] adding dot option to minimatch Signed-off-by: Justin De Burgo --- .../src/ingestion/CatalogRules.test.ts | 20 +++++++++++++++++++ .../src/ingestion/CatalogRules.ts | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts b/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts index 34e89fad29..592b1dda21 100644 --- a/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts +++ b/plugins/catalog-backend/src/ingestion/CatalogRules.test.ts @@ -35,6 +35,10 @@ const entity = { }; const location: Record = { + v: { + type: 'url', + target: 'https://github.com/b/c/blob/master/.folder/v.yaml', + }, w: { type: 'url', target: 'https://github.com/b/c/blob/master/w.yaml', @@ -263,4 +267,20 @@ describe('DefaultCatalogRulesEnforcer', () => { expect(enforcer.isAllowed(entity.component, location.z)).toBe(false); }); }); + + it('should allow locations with a hidden folder', () => { + const enforcer = DefaultCatalogRulesEnforcer.fromConfig( + new ConfigReader({ + catalog: { + rules: [ + { + allow: ['Component'], + locations: [{ type: 'url', pattern: 'https://github.com/b/**' }], + }, + ], + }, + }), + ); + expect(enforcer.isAllowed(entity.component, location.v)).toBe(true); + }); }); diff --git a/plugins/catalog-backend/src/ingestion/CatalogRules.ts b/plugins/catalog-backend/src/ingestion/CatalogRules.ts index 677649d4b2..21b2d05a46 100644 --- a/plugins/catalog-backend/src/ingestion/CatalogRules.ts +++ b/plugins/catalog-backend/src/ingestion/CatalogRules.ts @@ -186,7 +186,10 @@ export class DefaultCatalogRulesEnforcer implements CatalogRulesEnforcer { } if ( matcher.pattern && - !minimatch(location?.target, matcher.pattern, { nocase: true }) + !minimatch(location?.target, matcher.pattern, { + nocase: true, + dot: true, + }) ) { continue; } From 9f71a2fd20442888ccae9ed5c2da05e7ebfd686d Mon Sep 17 00:00:00 2001 From: Justin De Burgo Date: Tue, 7 Feb 2023 10:22:10 -0600 Subject: [PATCH 2/3] adding changelog Signed-off-by: Justin De Burgo --- .changeset/famous-squids-wonder.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/famous-squids-wonder.md diff --git a/.changeset/famous-squids-wonder.md b/.changeset/famous-squids-wonder.md new file mode 100644 index 0000000000..11ca76ddc1 --- /dev/null +++ b/.changeset/famous-squids-wonder.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Adding dot option to mini match used in catalog rules to allow for catalog imports with hidden folders From 0303587bcefb28694bd9d43d2fb6e8af2796ef7d Mon Sep 17 00:00:00 2001 From: Justin De Burgo <57914589+jpdeburgo@users.noreply.github.com> Date: Mon, 13 Feb 2023 09:21:44 -0600 Subject: [PATCH 3/3] Update .changeset/famous-squids-wonder.md Co-authored-by: Patrik Oldsberg Signed-off-by: Justin De Burgo <57914589+jpdeburgo@users.noreply.github.com> --- .changeset/famous-squids-wonder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/famous-squids-wonder.md b/.changeset/famous-squids-wonder.md index 11ca76ddc1..5b027e9a63 100644 --- a/.changeset/famous-squids-wonder.md +++ b/.changeset/famous-squids-wonder.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-backend': patch --- -Adding dot option to mini match used in catalog rules to allow for catalog imports with hidden folders +Location rule target patterns now also match hidden files, i.e. path components with a leading dot.