Skip to content

Commit

Permalink
Merge pull request #1 from caido-community/ib-initial
Browse files Browse the repository at this point in the history
Ib initial
  • Loading branch information
Corb3nik authored Sep 6, 2024
2 parents eb788bf + 45f14f3 commit 6b7b3d6
Show file tree
Hide file tree
Showing 91 changed files with 5,705 additions and 182 deletions.
28 changes: 28 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"indentStyle": "space"
},
"overrides": [
{
"include": ["*.vue"],
"linter": {
"rules": {
"style": {
"useConst": "off",
"useImportType": "off"
}
}
}
}
]
}
18 changes: 9 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"id": "starterkit-plugin",
"name": "StarterKit Plugin",
"id": "authmatrix",
"name": "AuthMatrix",
"version": "0.1.0",
"description": "This is a starterkit plugin",
"description": "Grid-based authorization testing across multiple users and roles.",
"author": {
"name": "Caido Labs Inc.",
"email": "[email protected]",
"url": "https://github.com/caido/starterkit-plugin"
"url": "https://github.com/caido-community/authmatrix"
},
"plugins": [
{
"kind": "frontend",
"id": "caido-extra-commands",
"name": "Extra Commands",
"id": "authmatrix-frontend",
"name": "Authmatrix Frontend",
"entrypoint": "frontend/script.js",
"style": "frontend/style.css",
"backend": {
"id": "caido-extra-commands-backend"
"id": "authmatrix-backend"
}
},
{
"kind": "backend",
"id": "caido-extra-commands-backend",
"name": "Extra Commands Backend",
"id": "authmatrix-backend",
"name": "Authmatrix Backend",
"runtime": "javascript",
"entrypoint": "backend/script.js"
}
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"license": "CC0-1.0",
"type": "module",
"scripts": {
"build": "node scripts/clean.js && pnpm -r build && node scripts/pack.js"
"typecheck": "pnpm -r typecheck",
"build": "node scripts/clean.js && pnpm -r build && node scripts/pack.js",
"lint": "biome check --write ./packages/*/src"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@caido/plugin-manifest": "0.1.3",
"jszip": "3.10.1",
"typescript": "5.4.3",
"typescript": "5.5.4",
"vite": "5.2.7"
}
}
8 changes: 6 additions & 2 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"name": "starterkit-plugin-backend",
"name": "backend",
"version": "0.1.0",
"description": "StarterKit plugin for Caido",
"author": "Caido Labs Inc. <[email protected]>",
"license": "CC0-1.0",
"type": "module",
"types": "src/index.ts",
"scripts": {
"typecheck": "tsc --noEmit",
"build": "vite build"
},
"dependencies": {
"shared": "workspace:*"
},
"devDependencies": {
"@caido/sdk-backend": "0.39.0"
"@caido/sdk-backend": "0.40.1-beta.7"
}
}
90 changes: 79 additions & 11 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,85 @@
import { Body } from "caido:utils";
import { SDK, DefineAPI } from "caido:plugin";
import type { DefineAPI, SDK } from "caido:plugin";
import {
getRequestResponse,
getResults,
runAnalysis,
} from "./services/analysis";
import { addRole, deleteRole, getRoles, updateRole } from "./services/roles";
import { getSettings, updateSettings } from "./services/settings";
import {
addTemplate,
deleteTemplate,
getTemplates,
registerTemplateEvents,
toggleTemplateRole,
toggleTemplateUser,
updateTemplate,
} from "./services/templates";
import { addUser, deleteUser, getUsers, updateUser } from "./services/users";

function generateNumber(sdk: SDK, min: number, max: number): number {
sdk.console.log(new Body("test")); // Example from utils

// Generate random number between min and max
return Math.floor(Math.random() * (max - min + 1) + min);
}
export type { BackendEvents } from "./types";

export type API = DefineAPI<{
generateNumber: typeof generateNumber;
// Role endpoints
getRoles: typeof getRoles;
addRole: typeof addRole;
updateRole: typeof updateRole;
deleteRole: typeof deleteRole;

// User endpoints
getUsers: typeof getUsers;
addUser: typeof addUser;
updateUser: typeof updateUser;
deleteUser: typeof deleteUser;

// Template endpoints
getTemplates: typeof getTemplates;
addTemplate: typeof addTemplate;
updateTemplate: typeof updateTemplate;
deleteTemplate: typeof deleteTemplate;
toggleTemplateRole: typeof toggleTemplateRole;
toggleTemplateUser: typeof toggleTemplateUser;

// Settings endpoints
getSettings: typeof getSettings;
updateSettings: typeof updateSettings;

// Analysis endpoints
runAnalysis: typeof runAnalysis;
getResults: typeof getResults;
getRequestResponse: typeof getRequestResponse;
}>;

export function init(sdk: SDK) {
sdk.api.register("generateNumber", generateNumber);
export function init(sdk: SDK<API>) {
// Role endpoints
sdk.api.register("getRoles", getRoles);
sdk.api.register("addRole", addRole);
sdk.api.register("updateRole", updateRole);
sdk.api.register("deleteRole", deleteRole);

// User endpoints
sdk.api.register("getUsers", getUsers);
sdk.api.register("addUser", addUser);
sdk.api.register("updateUser", updateUser);
sdk.api.register("deleteUser", deleteUser);

// Template endpoints
sdk.api.register("getTemplates", getTemplates);
sdk.api.register("addTemplate", addTemplate);
sdk.api.register("updateTemplate", updateTemplate);
sdk.api.register("deleteTemplate", deleteTemplate);
sdk.api.register("toggleTemplateRole", toggleTemplateRole);
sdk.api.register("toggleTemplateUser", toggleTemplateUser);

// Settings endpoints
sdk.api.register("getSettings", getSettings);
sdk.api.register("updateSettings", updateSettings);

// Analysis function
sdk.api.register("runAnalysis", runAnalysis);
sdk.api.register("getResults", getResults);
sdk.api.register("getRequestResponse", getRequestResponse);

// Events
registerTemplateEvents(sdk);
}
Loading

0 comments on commit 6b7b3d6

Please sign in to comment.