Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions backend/src/graphql/resolvers/techniqueResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,29 @@
* GraphQL -> Resolver -> Repository -> Drizzle -> MySQL
*/
import {
getAllTechniques,
getAllTechniquesGrid,
getTechniqueByMitreId,
getTechniqueSubTechniques,
getTechniqueSoftware,
getTechniqueThreatActors
} from "../../repositories/techniqueRepository.js";

export const techniqueResolvers = {
Query: {
/**
* Henter alle Techniques.
*/
allTechniques: async () => {
return getAllTechniques();
allTechniques: async (
_parent: unknown,
args: {
limit: number;
offset: number;
},
) => {
return getAllTechniquesGrid(
args.limit,
args.offset,
);
},

/**
Expand All @@ -32,5 +44,25 @@ export const techniqueResolvers = {
args.mitreId,
);
},
/**
* Henter alle subteknikker for en spesifikk teknikk
*/
getTechniqueSubTechniques: async (_parent: unknown, args: { mitreId: string }) => {
return getTechniqueSubTechniques(args.mitreId);
},

/**
* Henter all programvare for en spesifikk teknikk
*/
getTechniqueSoftware: async (_parent: unknown, args: { mitreId: string }) => {
return getTechniqueSoftware(args.mitreId);
},

/**
* Henter alle trusselaktører for en spesifikk teknikk
*/
getTechniqueThreatActors: async (_parent: unknown, args: { mitreId: string }) => {
return getTechniqueThreatActors(args.mitreId);
},
},
};
42 changes: 41 additions & 1 deletion backend/src/graphql/typeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ export const typeDefs = `#graphql
mitreId: String!
name: String!
description: String!
tactics: [String!]!
platforms: [String!]!
}
type TechniqueGrid {
mitreId: String!
name: String!
tactic: String!
platform: String!
}
type TechniqueGridResult {
items: [TechniqueGrid!]!
totalCount: Int!
}
type ThreatActorItem {
name: String!
}
type TacticGrid {
Expand Down Expand Up @@ -95,9 +115,29 @@ export const typeDefs = `#graphql
getThreatActorTechniques(mitreId: String!, limit: Int!, offset: Int!): AssociatedItemsPage!
getThreatActorSoftwares(mitreId: String!, limit: Int!, offset: Int!): AssociatedItemsPage!
allTechniques: [Technique!]!
######################################## Techinques vvvv
# Henter alle Techniques
allTechniques(
limit: Int!
offset: Int!
): TechniqueGridResult!
# Henter én Technique basert på MITRE-ID
techniqueByMitreId(mitreId: String!): Technique
getTechniqueThreatActors(
mitreId: String!
): [ThreatActorItem!]!
getTechniqueSoftware(
mitreId: String!
): [AssociatedItem!]!
getTechniqueSubTechniques(
mitreId: String!
): [Technique!]!
software: [Software!]!
softwareByMitreId(mitreId: String!): Software
Expand Down
Loading