Skip to content

Commit

Permalink
Merge pull request #395 from snyk-tech-services/fix/supported-manifes…
Browse files Browse the repository at this point in the history
…t-by-entitlements

fix: supported manifest types by entitlement
  • Loading branch information
lili2311 authored Dec 6, 2022
2 parents 7c7c078 + 3bba3ee commit 513097e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/lib/api/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import type { requestsManager } from 'snyk-request-manager';
import type { SnykProject } from '../../types';
const debug = debugLib('snyk:api-project');

interface BulkProjectUpdateResponse {
publicId: string;
name: string;
}
export async function deleteProjects(
orgId: string,
projects: string[],
): Promise<boolean> {
): Promise<BulkProjectUpdateResponse> {
const apiToken = getApiToken();
if (!(orgId && projects)) {
throw new Error(
Expand Down
14 changes: 10 additions & 4 deletions src/lib/supported-project-types/supported-manifests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,20 @@ export function getSCMSupportedManifests(
return Array.from(manifestFiles);
}

export function getSCMSupportedProjectTypes(): string[] {
export function getSCMSupportedProjectTypes(
orgEntitlements: SnykProductEntitlement[] = [],
): string[] {
const supported = [];

for (const [name, entry] of Object.entries({
const typesWithSCMSupport = Object.entries({
...OPEN_SOURCE_PACKAGE_MANAGERS,
...CLOUD_CONFIGS,
...DOCKER,
})) {
}).filter(([, config]) => config.isSupported);

for (const [name, entry] of typesWithSCMSupport) {
if (entry.entitlement && !orgEntitlements.includes(entry.entitlement)) {
continue;
}
if (entry.isSupported) {
supported.push(name);
}
Expand Down
28 changes: 27 additions & 1 deletion test/lib/supported-project-types/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,34 @@ test('SCM supported manifest files for specific project types', async () => {
expect(getSCMSupportedManifests(['dockerfile'])).toEqual([]);
});

test('SCM supported project types', async () => {
test('SCM supported project types default', async () => {
expect(getSCMSupportedProjectTypes().sort()).toEqual(
[
'npm',
'rubygems',
'yarn',
'yarn-workspace',
'maven',
'gradle',
'sbt',
'pip',
'golangdep',
'govendor',
'gomodules',
'nuget',
'composer',
'cocoapods',
].sort(),
);
});

test('SCM supported project types (OS & IAC & Docker)', async () => {
expect(
getSCMSupportedProjectTypes([
'dockerfileFromScm',
'infrastructureAsCode',
]).sort(),
).toEqual(
[
'npm',
'rubygems',
Expand Down

0 comments on commit 513097e

Please sign in to comment.