Skip to content

Commit 19c6f90

Browse files
committed
require enterprise organisation for tier 1 reachability
1 parent dc01d74 commit 19c6f90

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/commands/scan/perform-reachability-analysis.mts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
spawnCoana,
66
} from '../../utils/coana.mts'
77
import { setupSdk } from '../../utils/sdk.mts'
8+
import { fetchOrganization } from '../organization/fetch-organization-list.mts'
89

910
import type { CResult } from '../../types.mts'
1011
import type { PURL_Type } from '../../utils/ecosystem.mts'
@@ -47,6 +48,30 @@ export async function performReachabilityAnalysis(
4748
spinner,
4849
uploadManifests = true,
4950
} = { __proto__: null, ...options } as ReachabilityAnalysisOptions
51+
52+
// Check if user has enterprise plan for reachability analysis
53+
const orgsCResult = await fetchOrganization()
54+
if (!orgsCResult.ok) {
55+
return {
56+
ok: false,
57+
message: 'Unable to verify plan permissions',
58+
cause:
59+
'Failed to fetch organization information to verify enterprise plan access',
60+
}
61+
}
62+
63+
const organizations = Object.values(orgsCResult.data.organizations)
64+
const hasEnterprisePlan = organizations.some(org => org.plan === 'enterprise')
65+
66+
if (!hasEnterprisePlan) {
67+
return {
68+
ok: false,
69+
message: 'Tier 1 Reachability analysis requires an enterprise plan',
70+
cause:
71+
'This feature is only available for organizations with an enterprise plan. Please visit https://socket.dev/pricing to upgrade your plan.',
72+
}
73+
}
74+
5075
let tarHash: string | undefined
5176

5277
if (uploadManifests && orgSlug && packagePaths) {

0 commit comments

Comments
 (0)