GeezerVison is showing github.com — handled assets in not scanned status · contentstack/cli-plugins@25ed536
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1-7Lines changed: 1 addition & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | fileignoreconfig: | 2 | 2 |
| 3 | 3 | - filename: pnpm-lock.yaml | 4 | | - checksum: 31e333d6769adbaae042c92ea0930fab168a0e06fc1bda406d49fd1042a7a9c7 | 5 | | -- filename: packages/contentstack-audit/src/audit-base-command.ts | 6 | | - checksum: 14275f241e4a194cfd1fb33d277df194011eba4458ccaab7e0d0bd3a1c9ccfe7 | 7 | | -- filename: packages/contentstack-audit/src/modules/entries.ts | 8 | | - checksum: b0fa5f7b390ef2d64bd4834a5b848780b902373e2c644833842b42c6b767d54e | 9 | | -- filename: packages/contentstack-audit/test/unit/modules/entries.test.ts | 10 | | - checksum: ff448c79d436d5e8b141efcc76f19892bfe96039ea9a60fae4e995b5ccbc2960 | | 4 | + checksum: 423213f918d2052ec37ad421d23057e159c8633d200bfa688d34bbcb73a19285 | 11 | 5 | version: '1.0' |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-audit/src/config/index.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,6 +55,9 @@ const config = { | 55 | 55 | name: 'assets', | 56 | 56 | dirName: 'assets', | 57 | 57 | fileName: 'assets.json', | | 58 | + // Asset scan statuses that must block import/reference; any other value (including | | 59 | + // 'not_scanned', 'clean', or the field being absent) is treated as safe. | | 60 | + blockingScanStatuses: ['pending', 'quarantined'], | 58 | 61 | }, | 59 | 62 | environments: { | 60 | 63 | name: 'environments', | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-audit/src/modules/assets.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -187,7 +187,7 @@ export default class Assets { | 187 | 187 | log.debug(`Processing asset: ${assetUid}`, this.config.auditContext); | 188 | 188 |
| 189 | 189 | const scanStatus = this.assets[assetUid]?._asset_scan_status; | 190 | | - if (scanStatus && scanStatus !== 'clean') { | | 190 | + if (this.config.moduleConfig.assets.blockingScanStatuses.includes(scanStatus)) { | 191 | 191 | log.debug(`Asset ${assetUid} has a non-clean scan status: ${scanStatus}`, this.config.auditContext); | 192 | 192 | cliux.print($t(auditMsg.SCAN_ASSET_QUARANTINE_MSG, { uid: assetUid, status: scanStatus }), { | 193 | 193 | color: 'yellow', | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-audit/src/modules/entries.ts +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -929,16 +929,17 @@ export default class Entries { | 929 | 929 |
| 930 | 930 | /** | 931 | 931 | * Returns true when the given asset uid should be treated as unusable — either it doesn't | 932 | | - * exist in the exported assets.json at all, or it exists but its scan status is present and | 933 | | - * not 'clean' (e.g. 'pending'/'quarantined'). Returns false (never flag) when asset metadata | | 932 | + * exist in the exported assets.json at all, or it exists but its scan status is one of | | 933 | + * config.moduleConfig.assets.blockingScanStatuses (e.g. 'pending'/'quarantined'). Any other | | 934 | + * status — including 'clean', 'not_scanned' (org has asset scanning disabled), or the field | | 935 | + * being absent — is not a blocking condition. Returns false (never flag) when asset metadata | 934 | 936 | * wasn't available at all, since we can't validate what we don't have data for. | 935 | 937 | */ | 936 | 938 | isAssetBad(uid?: string): boolean { | 937 | 939 | if (!this.assetsDataAvailable || !uid) return false; | 938 | 940 | const assetRecord = this.assetMetaData[uid]; | 939 | 941 | if (!assetRecord) return true; | 940 | | - const scanStatus = assetRecord._asset_scan_status; | 941 | | - return Boolean(scanStatus) && scanStatus !== 'clean'; | | 942 | + return this.config.moduleConfig.assets.blockingScanStatuses.includes(assetRecord._asset_scan_status ?? ''); | 942 | 943 | } | 943 | 944 |
| 944 | 945 | /** | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-audit/test/unit/mock/contents/assets/chunk1-assets.json +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 29 | 29 | "url": "https://images.contentstack.io/v3/assets/blt/blt-no-status-asset/no-status.png", | 30 | 30 | "_version": 1, | 31 | 31 | "publish_details": [] | | 32 | + }, | | 33 | + "blt-not-scanned-asset": { | | 34 | + "uid": "blt-not-scanned-asset", | | 35 | + "filename": "not-scanned.png", | | 36 | + "url": "https://images.contentstack.io/v3/assets/blt/blt-not-scanned-asset/not-scanned.png", | | 37 | + "_version": 1, | | 38 | + "_asset_scan_status": "not_scanned", | | 39 | + "publish_details": [] | 32 | 40 | } | 33 | 41 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-audit/test/unit/modules/assets.test.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,6 +48,7 @@ describe('Assets module', () => { | 48 | 48 | }); | 49 | 49 | expect(assetsInstance.missingScanStatusAssets).to.not.have.property('blt-clean-asset'); | 50 | 50 | expect(assetsInstance.missingScanStatusAssets).to.not.have.property('blt-no-status-asset'); | | 51 | + expect(assetsInstance.missingScanStatusAssets).to.not.have.property('blt-not-scanned-asset'); | 51 | 52 | }); | 52 | 53 |
| 53 | 54 | fancy | @@ -69,6 +70,7 @@ describe('Assets module', () => { | 69 | 70 | expect(writtenContent).to.not.have.property('blt-quarantined-asset'); | 70 | 71 | expect(writtenContent).to.have.property('blt-clean-asset'); | 71 | 72 | expect(writtenContent).to.have.property('blt-no-status-asset'); | | 73 | + expect(writtenContent).to.have.property('blt-not-scanned-asset'); | 72 | 74 | }); | 73 | 75 | }); | 74 | 76 | }); |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-audit/test/unit/modules/entries.test.ts +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1557,6 +1557,10 @@ describe('Entries module', () => { | 1557 | 1557 | uid: 'blt-pending-asset', | 1558 | 1558 | _asset_scan_status: 'pending', | 1559 | 1559 | }); | | 1560 | + expect(ctInstance.assetMetaData['blt-not-scanned-asset']).to.deep.include({ | | 1561 | + uid: 'blt-not-scanned-asset', | | 1562 | + _asset_scan_status: 'not_scanned', | | 1563 | + }); | 1560 | 1564 | }); | 1561 | 1565 |
| 1562 | 1566 | fancy | @@ -1611,6 +1615,17 @@ describe('Entries module', () => { | 1611 | 1615 | expect(ctInstance.isAssetBad('blt-clean')).to.be.false; | 1612 | 1616 | expect(ctInstance.isAssetBad('blt-legacy')).to.be.false; | 1613 | 1617 | }); | | 1618 | + | | 1619 | + fancy | | 1620 | + .stdout({ print: process.env.PRINT === 'true' || false }) | | 1621 | + .it('returns false when the asset scan status is not_scanned (org has asset scanning disabled)', () => { | | 1622 | + const ctInstance = new Entries(constructorParam); | | 1623 | + (ctInstance as any).assetsDataAvailable = true; | | 1624 | + (ctInstance as any).assetMetaData = { | | 1625 | + 'blt-not-scanned': { uid: 'blt-not-scanned', _asset_scan_status: 'not_scanned' }, | | 1626 | + }; | | 1627 | + expect(ctInstance.isAssetBad('blt-not-scanned')).to.be.false; | | 1628 | + }); | 1614 | 1629 | }); | 1615 | 1630 |
| 1616 | 1631 | describe('validateFileField method', () => { | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-export/src/config/index.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -118,6 +118,9 @@ const config: DefaultConfig = { | 118 | 118 | displayExecutionTime: false, | 119 | 119 | enableDownloadStatus: false, | 120 | 120 | includeVersionedAssets: false, | | 121 | + // Asset scan statuses that must block download; any other value (including 'not_scanned', | | 122 | + // 'clean', or the field being absent) is treated as safe to download. | | 123 | + blockingScanStatuses: ['pending', 'quarantined'], | 121 | 124 | }, | 122 | 125 | content_types: { | 123 | 126 | dirName: 'content_types', | |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-export/src/export/modules/assets.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -337,7 +337,7 @@ export default class ExportAssets extends BaseClass { | 337 | 337 | listOfAssets = uniqBy(listOfAssets, 'url'); | 338 | 338 | log.debug(`Total unique assets to download: ${listOfAssets.length}`, this.exportConfig.context); | 339 | 339 |
| 340 | | - const isNotClean = (asset: any) => asset._asset_scan_status && asset._asset_scan_status !== 'clean'; | | 340 | + const isNotClean = (asset: any) => this.assetConfig.blockingScanStatuses.includes(asset._asset_scan_status); | 341 | 341 | const skippedAssets = filter(listOfAssets, isNotClean); | 342 | 342 | listOfAssets = filter(listOfAssets, (asset: any) => !isNotClean(asset)); | 343 | 343 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/contentstack-export/src/types/default-config.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -102,6 +102,7 @@ export default interface DefaultConfig { | 102 | 102 | displayExecutionTime: boolean; | 103 | 103 | enableDownloadStatus: boolean; | 104 | 104 | includeVersionedAssets: boolean; | | 105 | + blockingScanStatuses: string[]; | 105 | 106 | dependencies?: Modules[]; | 106 | 107 | }; | 107 | 108 | content_types: { | |
|