From b35a7596ef6279bb99b4d1d6059352fdf555377b Mon Sep 17 00:00:00 2001 From: Finlay Birnie Date: Thu, 12 Dec 2024 10:47:55 +0000 Subject: [PATCH 1/4] allow deploys to manage lambda role policy --- infra/modules/oidc/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/infra/modules/oidc/main.tf b/infra/modules/oidc/main.tf index 55b811c61..9099faf5e 100644 --- a/infra/modules/oidc/main.tf +++ b/infra/modules/oidc/main.tf @@ -60,6 +60,7 @@ data "aws_iam_policy_document" "deploy_backend_policy" { "iam:GetRole", "iam:GetInstanceProfile", "iam:PassRole", + "iam:PutRolePolicy", "kms:CreateGrant", "kms:Decrypt", "kms:DescribeKey", From 793d678d435df8a1fb1ad5926640d5e5217fe7e6 Mon Sep 17 00:00:00 2001 From: Finlay Birnie Date: Tue, 17 Dec 2024 12:04:08 +0000 Subject: [PATCH 2/4] change optional dependency stopping snyk from scanning --- api/package-lock.json | 26 +++++++++++++++++++++----- api/package.json | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/api/package-lock.json b/api/package-lock.json index d64d099cd..2586cfed3 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -72,7 +72,7 @@ "node": "20.x" }, "optionalDependencies": { - "swc.linux-x64-musl.node": "1.7.36" + "@swc/core-linux-x64-musl": "1.9.3" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -11910,13 +11910,12 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.7.39", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.7.39.tgz", - "integrity": "sha512-mg39pW5x/eqqpZDdtjZJxrUvQNSvJF4O8wCl37fbuFUqOtXs4TxsjZ0aolt876HXxxhsQl7rS+N4KioEMSgTZw==", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.9.3.tgz", + "integrity": "sha512-ILsGMgfnOz1HwdDz+ZgEuomIwkP1PHT6maigZxaCIuC6OPEhKE8uYna22uU63XvYcLQvZYDzpR3ms47WQPuNEg==", "cpu": [ "x64" ], - "dev": true, "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -11977,6 +11976,23 @@ "node": ">=10" } }, + "node_modules/@swc/core/node_modules/@swc/core-linux-x64-musl": { + "version": "1.7.39", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.7.39.tgz", + "integrity": "sha512-mg39pW5x/eqqpZDdtjZJxrUvQNSvJF4O8wCl37fbuFUqOtXs4TxsjZ0aolt876HXxxhsQl7rS+N4KioEMSgTZw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/counter": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", diff --git a/api/package.json b/api/package.json index 3fbdfcae1..4d0e21173 100644 --- a/api/package.json +++ b/api/package.json @@ -101,7 +101,7 @@ "typescript": "^5.2.2" }, "optionalDependencies": { - "swc.linux-x64-musl.node": "1.7.36" + "@swc/core-linux-x64-musl": "1.9.3" }, "overrides": { "fast-xml-parser": "^4.2.5", From 9cf91a1a35d052e5c604aa567f92c385363a7ff8 Mon Sep 17 00:00:00 2001 From: Finlay Birnie Date: Mon, 16 Dec 2024 09:14:50 +0000 Subject: [PATCH 3/4] get around prisma not finding openssl issue --- api/Dockerfile | 5 ++++- api/prisma/schema.prisma | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 06c4a12b4..270aa92d7 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -7,7 +7,10 @@ RUN apk add \ curl \ gnupg \ lsb-release \ - wget + wget \ + openssl \ + openssl-dev \ + libc6-compat # Dockerize is needed to sync containers startup ENV DOCKERIZE_VERSION v0.6.1 diff --git a/api/prisma/schema.prisma b/api/prisma/schema.prisma index 039108f98..f04c1057b 100644 --- a/api/prisma/schema.prisma +++ b/api/prisma/schema.prisma @@ -1,7 +1,7 @@ generator client { provider = "prisma-client-js" previewFeatures = ["fullTextSearch"] - binaryTargets = ["native", "rhel-openssl-3.0.x", "linux-arm64-openssl-3.0.x"] + binaryTargets = ["native", "linux-musl", "rhel-openssl-3.0.x", "linux-arm64-openssl-3.0.x"] } datasource db { From 5a5d247e55237fa5a6912d9855074003b4cff86e Mon Sep 17 00:00:00 2001 From: Finlay Birnie Date: Tue, 17 Dec 2024 15:48:55 +0000 Subject: [PATCH 4/4] add new flag categories --- .../migration.sql | 11 ++++++++++ api/prisma/schema.prisma | 3 +++ api/src/components/flag/controller.ts | 20 ++++++++++++------- api/src/components/flag/schema/createFlag.ts | 7 +++++-- api/src/lib/interface.ts | 8 -------- ui/src/config/values.ts | 12 +++++++++++ ui/src/lib/types.ts | 5 ++++- 7 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 api/prisma/migrations/20241217135037_add_flag_categories/migration.sql diff --git a/api/prisma/migrations/20241217135037_add_flag_categories/migration.sql b/api/prisma/migrations/20241217135037_add_flag_categories/migration.sql new file mode 100644 index 000000000..d220a7072 --- /dev/null +++ b/api/prisma/migrations/20241217135037_add_flag_categories/migration.sql @@ -0,0 +1,11 @@ +-- AlterEnum +-- This migration adds more than one value to an enum. +-- With PostgreSQL versions 11 and earlier, this is not possible +-- in a single migration. This can be worked around by creating +-- multiple migrations, each migration adding only one value to +-- the enum. + + +ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'UNDECLARED_AI'; +ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'NOT_IN_OCTOPUS_FORMAT'; +ALTER TYPE "PublicationFlagCategoryEnum" ADD VALUE 'IRRELEVANT_LINKED_PUBLICATION'; diff --git a/api/prisma/schema.prisma b/api/prisma/schema.prisma index 039108f98..0f3a62d39 100644 --- a/api/prisma/schema.prisma +++ b/api/prisma/schema.prisma @@ -354,6 +354,9 @@ enum PublicationFlagCategoryEnum { UNDECLARED_IMAGE_MANIPULATION COPYRIGHT INAPPROPRIATE + UNDECLARED_AI + NOT_IN_OCTOPUS_FORMAT + IRRELEVANT_LINKED_PUBLICATION } enum LicenceType { diff --git a/api/src/components/flag/controller.ts b/api/src/components/flag/controller.ts index bcabe14f8..2aee3000c 100644 --- a/api/src/components/flag/controller.ts +++ b/api/src/components/flag/controller.ts @@ -1,12 +1,13 @@ import * as cheerio from 'cheerio'; import nodemailer from 'nodemailer'; + +import * as email from 'lib/email'; +import * as flagService from 'flag/service'; import * as Helpers from 'lib/helpers'; -import * as response from 'lib/response'; +import * as I from 'interface'; import * as publicationService from 'publication/service'; -import * as flagService from 'flag/service'; +import * as response from 'lib/response'; import * as userService from 'user/service'; -import * as I from 'interface'; -import * as email from 'lib/email'; export const get = async (event: I.APIRequest): Promise => { try { @@ -48,14 +49,19 @@ export const getUserFlags = async ( } }; -const formatFlagType = (flagType: I.FlagCategory): string => { - const types = { +const formatFlagType = (flagType: I.PublicationFlagCategoryEnum): string => { + const types: { + [key in I.PublicationFlagCategoryEnum]: string; + } = { PLAGIARISM: 'Plagiarism', ETHICAL_ISSUES: 'Ethical issues', MISREPRESENTATION: 'Misrepresentation', UNDECLARED_IMAGE_MANIPULATION: 'Undeclared image manipulation', COPYRIGHT: 'Copyright', - INAPPROPRIATE: 'Inappropriate' + INAPPROPRIATE: 'Inappropriate', + UNDECLARED_AI: 'Undeclared use of generative AI', + NOT_IN_OCTOPUS_FORMAT: 'Not in Octopus format', + IRRELEVANT_LINKED_PUBLICATION: 'Linked to irrelevant publication' }; return types[flagType]; diff --git a/api/src/components/flag/schema/createFlag.ts b/api/src/components/flag/schema/createFlag.ts index ca1ebea31..bb3e09ccd 100644 --- a/api/src/components/flag/schema/createFlag.ts +++ b/api/src/components/flag/schema/createFlag.ts @@ -5,13 +5,16 @@ const updatedPublicationSchema: I.Schema = { properties: { category: { type: 'string', - enum: [ + enum: [ 'PLAGIARISM', 'ETHICAL_ISSUES', 'MISREPRESENTATION', 'UNDECLARED_IMAGE_MANIPULATION', 'COPYRIGHT', - 'INAPPROPRIATE' + 'INAPPROPRIATE', + 'UNDECLARED_AI', + 'NOT_IN_OCTOPUS_FORMAT', + 'IRRELEVANT_LINKED_PUBLICATION' ] }, comment: { diff --git a/api/src/lib/interface.ts b/api/src/lib/interface.ts index 6ed5c94c5..ea3ea277d 100644 --- a/api/src/lib/interface.ts +++ b/api/src/lib/interface.ts @@ -349,14 +349,6 @@ export interface ConfirmVerificationCodeBody { const prismaGeneratedFlagType = Prisma.validator()({}); export type Flag = Prisma.PublicationFlagsGetPayload; -export type FlagCategory = - | 'PLAGIARISM' - | 'ETHICAL_ISSUES' - | 'MISREPRESENTATION' - | 'UNDECLARED_IMAGE_MANIPULATION' - | 'COPYRIGHT' - | 'INAPPROPRIATE'; - export interface CreateFlagPathParams { publicationId: string; } diff --git a/ui/src/config/values.ts b/ui/src/config/values.ts index 72882be3f..44f2c3ce5 100644 --- a/ui/src/config/values.ts +++ b/ui/src/config/values.ts @@ -856,6 +856,18 @@ export const octopusInformation: Interfaces.OctopusInformation = { INAPPROPRIATE: { value: 'INAPPROPRIATE', nicename: 'Inappropriate' + }, + UNDECLARED_AI: { + value: 'UNDECLARED_AI', + nicename: 'Undeclared use of generative AI' + }, + NOT_IN_OCTOPUS_FORMAT: { + value: 'NOT_IN_OCTOPUS_FORMAT', + nicename: 'Not in Octopus format' + }, + IRRELEVANT_LINKED_PUBLICATION: { + value: 'IRRELEVANT_LINKED_PUBLICATION', + nicename: 'Linked to irrelevant publication' } } }; diff --git a/ui/src/lib/types.ts b/ui/src/lib/types.ts index 3641ac656..d9023edb4 100644 --- a/ui/src/lib/types.ts +++ b/ui/src/lib/types.ts @@ -112,7 +112,10 @@ export type RedFlagTypes = | 'MISREPRESENTATION' | 'UNDECLARED_IMAGE_MANIPULATION' | 'COPYRIGHT' - | 'INAPPROPRIATE'; + | 'INAPPROPRIATE' + | 'UNDECLARED_AI' + | 'NOT_IN_OCTOPUS_FORMAT' + | 'IRRELEVANT_LINKED_PUBLICATION'; export type Languages = | 'ab'