Skip to content

Commit

Permalink
Merge pull request #3672 from uselagoon/chore/remove_harbor_from_core
Browse files Browse the repository at this point in the history
Chore: Remove Harbor Trivy integration from Lagoon Core.
  • Loading branch information
tobybellwood authored Mar 15, 2024
2 parents 3a87f84 + 69c1c71 commit 0c024db
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 2,458 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function(knex) {
return knex.schema.dropTable('problem_harbor_scan_matcher');
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function(knex) {
return knex.schema.createTable('problem_harbor_scan_matcher', function (table) {
table.increments('id').notNullable().primary();
table.string('name', 100).notNullable();
table.text('description');
table.string('default_lagoon_project', 300);
table.string('default_lagoon_environment', 300);
table.string('default_lagoon_service_name', 300);
table.string('regex', 300).notNullable();
});
};
60 changes: 3 additions & 57 deletions services/api/src/resources/problem/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,7 @@ export const getProblemHarborScanMatches: ResolverFn = async (
args,
{ sqlClientPool, hasPermission }
) => {
await hasPermission('harbor_scan_match', 'view', {});

const rows = await query(
sqlClientPool,
Sql.selectAllProblemHarborScanMatches()
);

return rows;
throw new Error('Harbor-Trivy integration with core removed in Lagoon 2')
};

export const addProblemHarborScanMatch: ResolverFn = async (
Expand All @@ -297,60 +290,13 @@ export const addProblemHarborScanMatch: ResolverFn = async (
},
{ sqlClientPool, hasPermission, userActivityLogger }
) => {
await hasPermission('harbor_scan_match', 'add', {});

const { insertId } = await query(
sqlClientPool,
Sql.insertProblemHarborScanMatch({
id: null,
name,
description,
default_lagoon_project: defaultLagoonProject,
default_lagoon_environment: defaultLagoonEnvironment,
default_lagoon_service_name: defaultLagoonService,
regex
})
);

const rows = await query(
sqlClientPool,
Sql.selectAllProblemHarborScanMatchByDatabaseId(insertId)
);

userActivityLogger(`User added harbor scan regex matcher`, {
project: '',
event: 'api:addProblemHarborScanMatch',
payload: {
input: {
name,
description,
defaultLagoonProject,
defaultLagoonEnvironment,
defaultLagoonService,
regex
}
}
});

return R.prop(0, rows);
throw new Error('Harbor-Trivy integration with core removed in Lagoon 2')
};

export const deleteProblemHarborScanMatch: ResolverFn = async (
root,
{ input: { id } },
{ sqlClientPool, hasPermission, userActivityLogger }
) => {
await hasPermission('harbor_scan_match', 'delete', {});

await query(sqlClientPool, Sql.deleteProblemHarborScanMatch(id));

userActivityLogger(`User deleted harbor scan regex matcher`, {
project: '',
event: 'api:deleteProblemHarborScanMatch',
payload: {
input: { id }
}
});

return 'success';
throw new Error('Harbor-Trivy integration with core removed in Lagoon 2')
};
35 changes: 0 additions & 35 deletions services/api/src/resources/problem/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,40 +154,5 @@ export const Sql = {
lagoon_service: service
})
.del()
.toString(),
selectAllProblemHarborScanMatches: () =>
knex('problem_harbor_scan_matcher')
.select(standardProblemHarborScanMatchReturn)
.toString(),
selectAllProblemHarborScanMatchByDatabaseId: id =>
knex('problem_harbor_scan_matcher')
.select(standardProblemHarborScanMatchReturn)
.where({ id: id })
.toString(),
insertProblemHarborScanMatch: ({
id,
name,
description,
default_lagoon_project,
default_lagoon_environment,
default_lagoon_service_name,
regex
}) =>
knex('problem_harbor_scan_matcher')
.insert({
name,
description,
default_lagoon_project,
default_lagoon_environment,
default_lagoon_service_name,
regex
})
.toString(),
deleteProblemHarborScanMatch: id =>
knex('problem_harbor_scan_matcher')
.where({
id: id
})
.delete()
.toString()
};
6 changes: 3 additions & 3 deletions services/api/src/typeDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ const typeDefs = gql`
"""
Returns all ProblemHarborScanMatchers
"""
allProblemHarborScanMatchers: [ProblemHarborScanMatch]
allProblemHarborScanMatchers: [ProblemHarborScanMatch] @deprecated(reason: "Harbor-Trivy integration with core removed in Lagoon 2")
"""
Returns all AdvancedTaskDefinitions
"""
Expand Down Expand Up @@ -2413,10 +2413,10 @@ const typeDefs = gql`
cancelDeployment(input: CancelDeploymentInput!): String
addBackup(input: AddBackupInput!): Backup
addProblem(input: AddProblemInput!): Problem
addProblemHarborScanMatch(input: AddProblemHarborScanMatchInput!): ProblemHarborScanMatch
addProblemHarborScanMatch(input: AddProblemHarborScanMatchInput!): ProblemHarborScanMatch @deprecated(reason: "Harbor-Trivy integration with core removed in Lagoon 2")
deleteProblem(input: DeleteProblemInput!): String
deleteProblemsFromSource(input: DeleteProblemsFromSourceInput!): String
deleteProblemHarborScanMatch(input: DeleteProblemHarborScanMatchInput!): String
deleteProblemHarborScanMatch(input: DeleteProblemHarborScanMatchInput!): String @deprecated(reason: "Harbor-Trivy integration with core removed in Lagoon 2")
addFact(input: AddFactInput!): Fact
addFacts(input: AddFactsInput!): [Fact] @deprecated(reason: "Use addFactsByName instead")
addFactsByName(input: AddFactsByNameInput!): [Fact]
Expand Down
4 changes: 0 additions & 4 deletions services/webhook-handler/src/extractWebhookData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ export function extractWebhookData(req: IncomingMessage, body: string): WebhookR
webhooktype = 'resticbackup';
event = 'restore:finished';
uuid = uuid4();
} else if (bodyObj.type && (bodyObj.type == 'scanningCompleted' || bodyObj.type == 'SCANNING_COMPLETED')) {
webhooktype = 'problems';
event = 'harbor:scanningcompleted';
uuid = uuid4();
} else if (bodyObj.lagoonInfo) {
webhooktype = 'problems';
event = 'drutiny:resultset';
Expand Down
2 changes: 0 additions & 2 deletions services/webhooks2tasks/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ARG LAGOON_GIT_BRANCH
ARG IMAGE_REPO
ARG UPSTREAM_REPO
ARG UPSTREAM_TAG
ARG ENABLE_DEPRECATED_TRIVY_INTEGRATION=false
# STAGE 1: Loading Image lagoon-node-packages-builder which contains node packages shared by all Node Services
FROM ${IMAGE_REPO:-lagoon}/yarn-workspace-builder as yarn-workspace-builder

Expand All @@ -11,7 +10,6 @@ FROM ${UPSTREAM_REPO:-uselagoon}/node-20:${UPSTREAM_TAG:-latest}

ARG LAGOON_VERSION
ENV LAGOON_VERSION=$LAGOON_VERSION
ENV ENABLE_DEPRECATED_TRIVY_INTEGRATION=$ENABLE_DEPRECATED_TRIVY_INTEGRATION

# Copying generated node_modules from the first stage
COPY --from=yarn-workspace-builder /app /app
Expand Down

This file was deleted.

Loading

0 comments on commit 0c024db

Please sign in to comment.