mobbdev 1.0.209 → 1.0.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/args/commands/upload_ai_blame.d.mts +2 -0
- package/dist/index.mjs +2050 -207
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -6809,7 +6809,7 @@ function getBitbucketSdk(params) {
|
|
|
6809
6809
|
return repoRes.map((repo) => ({
|
|
6810
6810
|
repoIsPublic: !repo.is_private,
|
|
6811
6811
|
repoName: repo.name || "unknown repo name",
|
|
6812
|
-
repoOwner: repo.owner?.username || "unknown owner",
|
|
6812
|
+
repoOwner: repo.owner?.["username"] || "unknown owner",
|
|
6813
6813
|
repoLanguages: repo.language ? [repo.language] : [],
|
|
6814
6814
|
repoUpdatedAt: repo.updated_on ? repo.updated_on : (/* @__PURE__ */ new Date()).toISOString(),
|
|
6815
6815
|
repoUrl: repo.links?.html?.href || ""
|
|
@@ -7209,10 +7209,10 @@ var BitbucketSCMLib = class extends SCMLib {
|
|
|
7209
7209
|
async _getUsernameForAuthUrl() {
|
|
7210
7210
|
this._validateAccessTokenAndUrl();
|
|
7211
7211
|
const user = await this.bitbucketSdk.getUser();
|
|
7212
|
-
if (!user
|
|
7212
|
+
if (!user["username"]) {
|
|
7213
7213
|
throw new Error("no username found");
|
|
7214
7214
|
}
|
|
7215
|
-
return user
|
|
7215
|
+
return user["username"];
|
|
7216
7216
|
}
|
|
7217
7217
|
async getIsRemoteBranch(branch) {
|
|
7218
7218
|
this._validateAccessTokenAndUrl();
|
|
@@ -7233,7 +7233,7 @@ var BitbucketSCMLib = class extends SCMLib {
|
|
|
7233
7233
|
async getUsername() {
|
|
7234
7234
|
this._validateAccessToken();
|
|
7235
7235
|
const res = await this.bitbucketSdk.getUser();
|
|
7236
|
-
return z20.string().parse(res
|
|
7236
|
+
return z20.string().parse(res["username"]);
|
|
7237
7237
|
}
|
|
7238
7238
|
async getSubmitRequestStatus(_scmSubmitRequestId) {
|
|
7239
7239
|
this._validateAccessTokenAndUrl();
|
|
@@ -7564,13 +7564,33 @@ function getGithubSdk(params = {}) {
|
|
|
7564
7564
|
const { username, repoUrl } = params2;
|
|
7565
7565
|
try {
|
|
7566
7566
|
const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7567
|
+
try {
|
|
7568
|
+
const res = await octokit.rest.repos.checkCollaborator({
|
|
7569
|
+
owner,
|
|
7570
|
+
repo,
|
|
7571
|
+
username
|
|
7572
|
+
});
|
|
7573
|
+
if (res.status === 204) {
|
|
7574
|
+
return true;
|
|
7575
|
+
}
|
|
7576
|
+
} catch (collaboratorError) {
|
|
7577
|
+
try {
|
|
7578
|
+
const permissionRes = await octokit.rest.repos.getCollaboratorPermissionLevel({
|
|
7579
|
+
owner,
|
|
7580
|
+
repo,
|
|
7581
|
+
username
|
|
7582
|
+
});
|
|
7583
|
+
if (permissionRes.data.permission !== "none") {
|
|
7584
|
+
return true;
|
|
7585
|
+
}
|
|
7586
|
+
} catch (permissionError) {
|
|
7587
|
+
try {
|
|
7588
|
+
await octokit.rest.repos.get({ owner, repo });
|
|
7589
|
+
return true;
|
|
7590
|
+
} catch (repoError) {
|
|
7591
|
+
return false;
|
|
7592
|
+
}
|
|
7593
|
+
}
|
|
7574
7594
|
}
|
|
7575
7595
|
} catch (e) {
|
|
7576
7596
|
return false;
|
|
@@ -7645,6 +7665,9 @@ function getGithubSdk(params = {}) {
|
|
|
7645
7665
|
const repos = await octokit.rest.repos.get({ repo, owner });
|
|
7646
7666
|
return repos.data.default_branch;
|
|
7647
7667
|
},
|
|
7668
|
+
async getRepository({ owner, repo }) {
|
|
7669
|
+
return octokit.rest.repos.get({ repo, owner });
|
|
7670
|
+
},
|
|
7648
7671
|
async getGithubReferenceData({
|
|
7649
7672
|
ref,
|
|
7650
7673
|
gitHubUrl
|
|
@@ -7904,11 +7927,12 @@ function getGithubSdk(params = {}) {
|
|
|
7904
7927
|
return octokit.request(GET_USER);
|
|
7905
7928
|
},
|
|
7906
7929
|
async getPrCommits(params2) {
|
|
7907
|
-
|
|
7930
|
+
const data = await octokit.paginate(octokit.rest.pulls.listCommits, {
|
|
7908
7931
|
owner: params2.owner,
|
|
7909
7932
|
repo: params2.repo,
|
|
7910
7933
|
pull_number: params2.pull_number
|
|
7911
7934
|
});
|
|
7935
|
+
return { data };
|
|
7912
7936
|
},
|
|
7913
7937
|
async getUserRepos() {
|
|
7914
7938
|
return octokit.rest.repos.listForAuthenticatedUser({
|
|
@@ -7929,12 +7953,12 @@ function getGithubSdk(params = {}) {
|
|
|
7929
7953
|
});
|
|
7930
7954
|
},
|
|
7931
7955
|
async listPRFiles(params2) {
|
|
7932
|
-
|
|
7956
|
+
const data = await octokit.paginate(octokit.rest.pulls.listFiles, {
|
|
7933
7957
|
owner: params2.owner,
|
|
7934
7958
|
repo: params2.repo,
|
|
7935
|
-
pull_number: params2.pull_number
|
|
7936
|
-
per_page: 100
|
|
7959
|
+
pull_number: params2.pull_number
|
|
7937
7960
|
});
|
|
7961
|
+
return { data };
|
|
7938
7962
|
}
|
|
7939
7963
|
};
|
|
7940
7964
|
}
|
|
@@ -8204,13 +8228,54 @@ var GithubSCMLib = class extends SCMLib {
|
|
|
8204
8228
|
commitSha
|
|
8205
8229
|
});
|
|
8206
8230
|
const commitTimestamp = commit.commit.committer?.date ? new Date(commit.commit.committer.date) : new Date(commit.commit.author?.date || Date.now());
|
|
8231
|
+
let parentCommits;
|
|
8232
|
+
if (commit.parents && commit.parents.length > 0) {
|
|
8233
|
+
try {
|
|
8234
|
+
parentCommits = await Promise.all(
|
|
8235
|
+
commit.parents.map(async (parent) => {
|
|
8236
|
+
const parentCommit = await this.githubSdk.getCommit({
|
|
8237
|
+
owner,
|
|
8238
|
+
repo,
|
|
8239
|
+
commitSha: parent.sha
|
|
8240
|
+
});
|
|
8241
|
+
const parentTimestamp = parentCommit.data.committer?.date ? new Date(parentCommit.data.committer.date) : new Date(Date.now());
|
|
8242
|
+
return {
|
|
8243
|
+
sha: parent.sha,
|
|
8244
|
+
timestamp: parentTimestamp
|
|
8245
|
+
};
|
|
8246
|
+
})
|
|
8247
|
+
);
|
|
8248
|
+
} catch (error) {
|
|
8249
|
+
console.error("Failed to fetch parent commit timestamps", {
|
|
8250
|
+
error,
|
|
8251
|
+
commitSha,
|
|
8252
|
+
owner,
|
|
8253
|
+
repo
|
|
8254
|
+
});
|
|
8255
|
+
parentCommits = void 0;
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8258
|
+
let repositoryCreatedAt;
|
|
8259
|
+
try {
|
|
8260
|
+
const repoData = await this.githubSdk.getRepository({ owner, repo });
|
|
8261
|
+
repositoryCreatedAt = repoData.data.created_at ? new Date(repoData.data.created_at) : void 0;
|
|
8262
|
+
} catch (error) {
|
|
8263
|
+
console.error("Failed to fetch repository creation date", {
|
|
8264
|
+
error,
|
|
8265
|
+
owner,
|
|
8266
|
+
repo
|
|
8267
|
+
});
|
|
8268
|
+
repositoryCreatedAt = void 0;
|
|
8269
|
+
}
|
|
8207
8270
|
return {
|
|
8208
8271
|
diff,
|
|
8209
8272
|
commitTimestamp,
|
|
8210
8273
|
commitSha: commit.sha,
|
|
8211
8274
|
authorName: commit.commit.author?.name,
|
|
8212
8275
|
authorEmail: commit.commit.author?.email,
|
|
8213
|
-
message: commit.commit.message
|
|
8276
|
+
message: commit.commit.message,
|
|
8277
|
+
parentCommits,
|
|
8278
|
+
repositoryCreatedAt
|
|
8214
8279
|
};
|
|
8215
8280
|
}
|
|
8216
8281
|
async getSubmitRequestDiff(submitRequestId) {
|
|
@@ -12779,6 +12844,8 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
12779
12844
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12780
12845
|
import {
|
|
12781
12846
|
CallToolRequestSchema,
|
|
12847
|
+
GetPromptRequestSchema,
|
|
12848
|
+
ListPromptsRequestSchema,
|
|
12782
12849
|
ListToolsRequestSchema
|
|
12783
12850
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
12784
12851
|
|
|
@@ -14409,6 +14476,45 @@ var MCP_TOOL_CHECKER = "mcp_checker";
|
|
|
14409
14476
|
// src/mcp/core/McpServer.ts
|
|
14410
14477
|
init_configs();
|
|
14411
14478
|
|
|
14479
|
+
// src/mcp/core/PromptRegistry.ts
|
|
14480
|
+
var PromptRegistry = class {
|
|
14481
|
+
constructor() {
|
|
14482
|
+
__publicField(this, "prompts", /* @__PURE__ */ new Map());
|
|
14483
|
+
}
|
|
14484
|
+
registerPrompt(prompt) {
|
|
14485
|
+
if (this.prompts.has(prompt.name)) {
|
|
14486
|
+
logWarn(`Prompt ${prompt.name} is already registered, overwriting`, {
|
|
14487
|
+
promptName: prompt.name
|
|
14488
|
+
});
|
|
14489
|
+
}
|
|
14490
|
+
this.prompts.set(prompt.name, prompt);
|
|
14491
|
+
logDebug(`Prompt registered: ${prompt.name}`, {
|
|
14492
|
+
promptName: prompt.name,
|
|
14493
|
+
description: prompt.description
|
|
14494
|
+
});
|
|
14495
|
+
}
|
|
14496
|
+
getPrompt(name) {
|
|
14497
|
+
return this.prompts.get(name);
|
|
14498
|
+
}
|
|
14499
|
+
getPromptDefinition(name) {
|
|
14500
|
+
return this.prompts.get(name)?.getDefinition();
|
|
14501
|
+
}
|
|
14502
|
+
getAllPrompts() {
|
|
14503
|
+
return Array.from(this.prompts.values()).map(
|
|
14504
|
+
(prompt) => prompt.getDefinition()
|
|
14505
|
+
);
|
|
14506
|
+
}
|
|
14507
|
+
getPromptNames() {
|
|
14508
|
+
return Array.from(this.prompts.keys());
|
|
14509
|
+
}
|
|
14510
|
+
hasPrompt(name) {
|
|
14511
|
+
return this.prompts.has(name);
|
|
14512
|
+
}
|
|
14513
|
+
getPromptCount() {
|
|
14514
|
+
return this.prompts.size;
|
|
14515
|
+
}
|
|
14516
|
+
};
|
|
14517
|
+
|
|
14412
14518
|
// src/mcp/core/ToolRegistry.ts
|
|
14413
14519
|
var ToolRegistry = class {
|
|
14414
14520
|
constructor() {
|
|
@@ -14451,6 +14557,7 @@ var McpServer = class {
|
|
|
14451
14557
|
constructor(config6, govOrgId = "") {
|
|
14452
14558
|
__publicField(this, "server");
|
|
14453
14559
|
__publicField(this, "toolRegistry");
|
|
14560
|
+
__publicField(this, "promptRegistry");
|
|
14454
14561
|
__publicField(this, "isEventHandlersSetup", false);
|
|
14455
14562
|
__publicField(this, "eventHandlers", /* @__PURE__ */ new Map());
|
|
14456
14563
|
__publicField(this, "parentProcessCheckInterval");
|
|
@@ -14466,11 +14573,13 @@ var McpServer = class {
|
|
|
14466
14573
|
},
|
|
14467
14574
|
{
|
|
14468
14575
|
capabilities: {
|
|
14469
|
-
tools: {}
|
|
14576
|
+
tools: {},
|
|
14577
|
+
prompts: {}
|
|
14470
14578
|
}
|
|
14471
14579
|
}
|
|
14472
14580
|
);
|
|
14473
14581
|
this.toolRegistry = new ToolRegistry();
|
|
14582
|
+
this.promptRegistry = new PromptRegistry();
|
|
14474
14583
|
this.setupHandlers();
|
|
14475
14584
|
this.setupProcessEventHandlers();
|
|
14476
14585
|
this.setupParentProcessMonitoring();
|
|
@@ -14787,6 +14896,56 @@ var McpServer = class {
|
|
|
14787
14896
|
throw error;
|
|
14788
14897
|
}
|
|
14789
14898
|
}
|
|
14899
|
+
async handleListPromptsRequest(request) {
|
|
14900
|
+
logInfo("Received list_prompts request");
|
|
14901
|
+
logDebug("list_prompts request", {
|
|
14902
|
+
request: JSON.parse(JSON.stringify(request))
|
|
14903
|
+
});
|
|
14904
|
+
const promptDefinitions = this.promptRegistry.getAllPrompts();
|
|
14905
|
+
const response = {
|
|
14906
|
+
prompts: promptDefinitions.map((prompt) => ({
|
|
14907
|
+
name: prompt.name,
|
|
14908
|
+
description: prompt.description,
|
|
14909
|
+
arguments: prompt.arguments
|
|
14910
|
+
}))
|
|
14911
|
+
};
|
|
14912
|
+
logDebug("Returning list_prompts response", { response });
|
|
14913
|
+
return response;
|
|
14914
|
+
}
|
|
14915
|
+
async handleGetPromptRequest(request) {
|
|
14916
|
+
const { name, arguments: args } = request.params;
|
|
14917
|
+
logInfo(`Received get_prompt request for ${name}`);
|
|
14918
|
+
logDebug("get_prompt request", {
|
|
14919
|
+
request: JSON.parse(JSON.stringify(request))
|
|
14920
|
+
});
|
|
14921
|
+
try {
|
|
14922
|
+
const prompt = this.promptRegistry.getPrompt(name);
|
|
14923
|
+
if (!prompt) {
|
|
14924
|
+
const errorMsg = `Unknown prompt: ${name}`;
|
|
14925
|
+
logWarn(errorMsg, {
|
|
14926
|
+
name,
|
|
14927
|
+
availablePrompts: this.promptRegistry.getPromptNames()
|
|
14928
|
+
});
|
|
14929
|
+
throw new Error(errorMsg);
|
|
14930
|
+
}
|
|
14931
|
+
logInfo(`Generating prompt: ${name}`);
|
|
14932
|
+
const response = await prompt.getPrompt(args);
|
|
14933
|
+
logInfo(`Prompt ${name} generated successfully`);
|
|
14934
|
+
logDebug(`Prompt ${name} generated successfully`, {
|
|
14935
|
+
hasMessages: !!response.messages,
|
|
14936
|
+
messageCount: response.messages?.length
|
|
14937
|
+
});
|
|
14938
|
+
return response;
|
|
14939
|
+
} catch (error) {
|
|
14940
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
14941
|
+
logError(`Error generating prompt ${name}: ${errorMessage}`, {
|
|
14942
|
+
error,
|
|
14943
|
+
promptName: name,
|
|
14944
|
+
args
|
|
14945
|
+
});
|
|
14946
|
+
throw error;
|
|
14947
|
+
}
|
|
14948
|
+
}
|
|
14790
14949
|
setupHandlers() {
|
|
14791
14950
|
this.server.setRequestHandler(
|
|
14792
14951
|
ListToolsRequestSchema,
|
|
@@ -14796,12 +14955,24 @@ var McpServer = class {
|
|
|
14796
14955
|
CallToolRequestSchema,
|
|
14797
14956
|
(request) => this.handleCallToolRequest(request)
|
|
14798
14957
|
);
|
|
14958
|
+
this.server.setRequestHandler(
|
|
14959
|
+
ListPromptsRequestSchema,
|
|
14960
|
+
(request) => this.handleListPromptsRequest(request)
|
|
14961
|
+
);
|
|
14962
|
+
this.server.setRequestHandler(
|
|
14963
|
+
GetPromptRequestSchema,
|
|
14964
|
+
(request) => this.handleGetPromptRequest(request)
|
|
14965
|
+
);
|
|
14799
14966
|
logInfo("MCP server handlers registered");
|
|
14800
14967
|
}
|
|
14801
14968
|
registerTool(tool) {
|
|
14802
14969
|
this.toolRegistry.registerTool(tool);
|
|
14803
14970
|
logInfo(`Tool registered: ${tool.name}`);
|
|
14804
14971
|
}
|
|
14972
|
+
registerPrompt(prompt) {
|
|
14973
|
+
this.promptRegistry.registerPrompt(prompt);
|
|
14974
|
+
logInfo(`Prompt registered: ${prompt.name}`);
|
|
14975
|
+
}
|
|
14805
14976
|
getParentProcessId() {
|
|
14806
14977
|
return this.parentPid;
|
|
14807
14978
|
}
|
|
@@ -14865,117 +15036,43 @@ var McpServer = class {
|
|
|
14865
15036
|
}
|
|
14866
15037
|
};
|
|
14867
15038
|
|
|
14868
|
-
// src/mcp/
|
|
14869
|
-
import { z as
|
|
14870
|
-
|
|
14871
|
-
// src/mcp/services/PathValidation.ts
|
|
14872
|
-
import fs12 from "fs";
|
|
14873
|
-
import path12 from "path";
|
|
14874
|
-
async function validatePath(inputPath) {
|
|
14875
|
-
logDebug("Validating MCP path", { inputPath });
|
|
14876
|
-
if (/^\/[a-zA-Z]:\//.test(inputPath)) {
|
|
14877
|
-
inputPath = inputPath.slice(1);
|
|
14878
|
-
}
|
|
14879
|
-
if (inputPath === "." || inputPath === "./") {
|
|
14880
|
-
const workspaceFolderPath = WorkspaceService.getWorkspaceFolderPath();
|
|
14881
|
-
if (workspaceFolderPath) {
|
|
14882
|
-
logDebug("Fallback to workspace folder path", {
|
|
14883
|
-
inputPath,
|
|
14884
|
-
workspaceFolderPaths: [workspaceFolderPath]
|
|
14885
|
-
});
|
|
14886
|
-
WorkspaceService.setKnownWorkspacePath(workspaceFolderPath);
|
|
14887
|
-
logDebug("Stored workspace folder path as known path", {
|
|
14888
|
-
workspaceFolderPath
|
|
14889
|
-
});
|
|
14890
|
-
return {
|
|
14891
|
-
isValid: true,
|
|
14892
|
-
path: workspaceFolderPath
|
|
14893
|
-
};
|
|
14894
|
-
} else {
|
|
14895
|
-
const error = `"." is not a valid path, please provide a full localpath to the repository`;
|
|
14896
|
-
logError(error);
|
|
14897
|
-
return { isValid: false, error, path: inputPath };
|
|
14898
|
-
}
|
|
14899
|
-
}
|
|
14900
|
-
if (inputPath.includes("..")) {
|
|
14901
|
-
const error = `Path contains path traversal patterns: ${inputPath}`;
|
|
14902
|
-
logError(error);
|
|
14903
|
-
return { isValid: false, error, path: inputPath };
|
|
14904
|
-
}
|
|
14905
|
-
const normalizedPath = path12.normalize(inputPath);
|
|
14906
|
-
if (normalizedPath.includes("..")) {
|
|
14907
|
-
const error = `Normalized path contains path traversal patterns: ${inputPath}`;
|
|
14908
|
-
logError(error);
|
|
14909
|
-
return { isValid: false, error, path: inputPath };
|
|
14910
|
-
}
|
|
14911
|
-
let decodedPath;
|
|
14912
|
-
try {
|
|
14913
|
-
decodedPath = decodeURIComponent(inputPath);
|
|
14914
|
-
} catch (err) {
|
|
14915
|
-
const error = `Failed to decode path: ${inputPath}`;
|
|
14916
|
-
logError(error, { err });
|
|
14917
|
-
return { isValid: false, error, path: inputPath };
|
|
14918
|
-
}
|
|
14919
|
-
if (decodedPath.includes("..") || decodedPath !== inputPath) {
|
|
14920
|
-
const error = `Path contains encoded traversal attempts: ${inputPath}`;
|
|
14921
|
-
logError(error);
|
|
14922
|
-
return { isValid: false, error, path: inputPath };
|
|
14923
|
-
}
|
|
14924
|
-
if (inputPath.includes("\0") || inputPath.includes("\0")) {
|
|
14925
|
-
const error = `Path contains dangerous characters: ${inputPath}`;
|
|
14926
|
-
logError(error);
|
|
14927
|
-
return { isValid: false, error, path: inputPath };
|
|
14928
|
-
}
|
|
14929
|
-
logDebug("Path validation successful", { inputPath });
|
|
14930
|
-
logDebug("Checking path existence", { inputPath });
|
|
14931
|
-
try {
|
|
14932
|
-
await fs12.promises.access(inputPath);
|
|
14933
|
-
logDebug("Path exists and is accessible", { inputPath });
|
|
14934
|
-
WorkspaceService.setKnownWorkspacePath(inputPath);
|
|
14935
|
-
logDebug("Stored validated path in WorkspaceService", { inputPath });
|
|
14936
|
-
return { isValid: true, path: inputPath };
|
|
14937
|
-
} catch (error) {
|
|
14938
|
-
const errorMessage = `Path does not exist or is not accessible: ${inputPath}`;
|
|
14939
|
-
logError(errorMessage, { error });
|
|
14940
|
-
return { isValid: false, error: errorMessage, path: inputPath };
|
|
14941
|
-
}
|
|
14942
|
-
}
|
|
15039
|
+
// src/mcp/prompts/CheckForNewVulnerabilitiesPrompt.ts
|
|
15040
|
+
import { z as z33 } from "zod";
|
|
14943
15041
|
|
|
14944
|
-
// src/mcp/
|
|
15042
|
+
// src/mcp/prompts/base/BasePrompt.ts
|
|
14945
15043
|
import { z as z32 } from "zod";
|
|
14946
|
-
var
|
|
15044
|
+
var BasePrompt = class {
|
|
14947
15045
|
getDefinition() {
|
|
14948
15046
|
return {
|
|
14949
15047
|
name: this.name,
|
|
14950
|
-
display_name: this.displayName,
|
|
14951
15048
|
description: this.description,
|
|
14952
|
-
|
|
15049
|
+
arguments: this.arguments
|
|
14953
15050
|
};
|
|
14954
15051
|
}
|
|
14955
|
-
async
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
15052
|
+
async getPrompt(args) {
|
|
15053
|
+
let validatedArgs = args;
|
|
15054
|
+
if (this.argumentsValidationSchema) {
|
|
15055
|
+
validatedArgs = this.validateArguments(args);
|
|
15056
|
+
logDebug(`Prompt ${this.name} arguments validation successful`, {
|
|
15057
|
+
validatedArgs
|
|
15058
|
+
});
|
|
14961
15059
|
}
|
|
14962
|
-
const
|
|
14963
|
-
logDebug(`
|
|
14964
|
-
validatedArgs
|
|
14965
|
-
});
|
|
14966
|
-
logInfo(`Executing tool: ${this.name}`);
|
|
14967
|
-
const result = await this.executeInternal(validatedArgs);
|
|
14968
|
-
logInfo(`Tool ${this.name} executed successfully`);
|
|
15060
|
+
const result = await this.generatePrompt(validatedArgs);
|
|
15061
|
+
logDebug(`Prompt ${this.name} generated successfully`);
|
|
14969
15062
|
return result;
|
|
14970
15063
|
}
|
|
14971
|
-
|
|
15064
|
+
validateArguments(args) {
|
|
15065
|
+
if (!this.argumentsValidationSchema) {
|
|
15066
|
+
return args;
|
|
15067
|
+
}
|
|
14972
15068
|
try {
|
|
14973
|
-
|
|
15069
|
+
const argsToValidate = args === void 0 ? {} : args;
|
|
15070
|
+
return this.argumentsValidationSchema.parse(argsToValidate);
|
|
14974
15071
|
} catch (error) {
|
|
14975
15072
|
if (error instanceof z32.ZodError) {
|
|
14976
15073
|
const errorDetails = error.errors.map((e) => {
|
|
14977
15074
|
const fieldPath = e.path.length > 0 ? e.path.join(".") : "root";
|
|
14978
|
-
const message = e.message === "Required" ? `Missing required
|
|
15075
|
+
const message = e.message === "Required" ? `Missing required argument '${fieldPath}'` : `Invalid value for '${fieldPath}': ${e.message}`;
|
|
14979
15076
|
return message;
|
|
14980
15077
|
});
|
|
14981
15078
|
const errorMessage = `Invalid arguments: ${errorDetails.join(", ")}`;
|
|
@@ -14984,84 +15081,1817 @@ var BaseTool = class {
|
|
|
14984
15081
|
throw error;
|
|
14985
15082
|
}
|
|
14986
15083
|
}
|
|
14987
|
-
|
|
15084
|
+
createUserMessage(text) {
|
|
14988
15085
|
return {
|
|
14989
|
-
|
|
15086
|
+
description: this.description,
|
|
15087
|
+
messages: [
|
|
14990
15088
|
{
|
|
14991
|
-
|
|
14992
|
-
|
|
15089
|
+
role: "user",
|
|
15090
|
+
content: {
|
|
15091
|
+
type: "text",
|
|
15092
|
+
text
|
|
15093
|
+
}
|
|
14993
15094
|
}
|
|
14994
15095
|
]
|
|
14995
15096
|
};
|
|
14996
15097
|
}
|
|
14997
15098
|
};
|
|
14998
15099
|
|
|
14999
|
-
// src/mcp/
|
|
15000
|
-
|
|
15100
|
+
// src/mcp/prompts/CheckForNewVulnerabilitiesPrompt.ts
|
|
15101
|
+
var CheckForNewVulnerabilitiesArgsSchema = z33.object({
|
|
15102
|
+
path: z33.string().optional()
|
|
15103
|
+
});
|
|
15104
|
+
var CheckForNewVulnerabilitiesPrompt = class extends BasePrompt {
|
|
15105
|
+
constructor() {
|
|
15106
|
+
super(...arguments);
|
|
15107
|
+
__publicField(this, "name", "check-for-new-vulnerabilities");
|
|
15108
|
+
__publicField(this, "description", "Guide for enabling continuous security monitoring to detect new vulnerabilities");
|
|
15109
|
+
__publicField(this, "arguments", [
|
|
15110
|
+
{
|
|
15111
|
+
name: "path",
|
|
15112
|
+
description: "Optional: Full local path to the git repository to monitor",
|
|
15113
|
+
required: false
|
|
15114
|
+
}
|
|
15115
|
+
]);
|
|
15116
|
+
__publicField(this, "argumentsValidationSchema", CheckForNewVulnerabilitiesArgsSchema);
|
|
15117
|
+
}
|
|
15118
|
+
async generatePrompt(validatedArgs) {
|
|
15119
|
+
const args = validatedArgs;
|
|
15120
|
+
const promptText = `# Continuous Security Monitoring Setup
|
|
15001
15121
|
|
|
15002
|
-
|
|
15003
|
-
|
|
15004
|
-
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15122
|
+
This workflow sets up ongoing security monitoring to detect new vulnerabilities as code changes.
|
|
15123
|
+
|
|
15124
|
+
## Purpose
|
|
15125
|
+
|
|
15126
|
+
The \`check_for_new_available_fixes\` tool provides:
|
|
15127
|
+
- Lightweight background security monitoring
|
|
15128
|
+
- Detection of newly introduced vulnerabilities
|
|
15129
|
+
- Periodic checks without heavy scanning overhead
|
|
15130
|
+
- Notifications when new fixes become available
|
|
15131
|
+
|
|
15132
|
+
## When to Use
|
|
15133
|
+
|
|
15134
|
+
Call this tool:
|
|
15135
|
+
\u2713 At the end of a coding session
|
|
15136
|
+
\u2713 After completing a series of edits
|
|
15137
|
+
\u2713 After applying security fixes (to verify no new issues)
|
|
15138
|
+
\u2713 Before committing code changes
|
|
15139
|
+
\u2713 As part of a continuous security workflow
|
|
15140
|
+
\u2713 When setting up a project for security monitoring
|
|
15141
|
+
|
|
15142
|
+
## Workflow Steps
|
|
15143
|
+
|
|
15144
|
+
### Step 1: Determine Repository Path
|
|
15145
|
+
${args?.path ? `\u2713 Repository path provided: \`${args.path}\`` : `Get the full local path to the git repository to monitor.`}
|
|
15146
|
+
|
|
15147
|
+
### Step 2: Call check_for_new_available_fixes
|
|
15148
|
+
|
|
15149
|
+
Use the tool with minimal parameters:
|
|
15150
|
+
|
|
15151
|
+
\`\`\`json
|
|
15152
|
+
{
|
|
15153
|
+
"path": "${args?.path || "<repository-path>"}"
|
|
15008
15154
|
}
|
|
15009
|
-
|
|
15010
|
-
`;
|
|
15011
|
-
var noFixesReturnedForParametersWithGuidance = ({
|
|
15012
|
-
offset,
|
|
15013
|
-
limit,
|
|
15014
|
-
totalCount,
|
|
15015
|
-
currentTool
|
|
15016
|
-
}) => `## No Fixes Returned for Current Parameters
|
|
15155
|
+
\`\`\`
|
|
15017
15156
|
|
|
15018
|
-
|
|
15019
|
-
- **Page:** ${Math.floor(offset / limit) + 1}
|
|
15020
|
-
- **Offset:** ${offset}
|
|
15021
|
-
- **Limit:** ${limit}
|
|
15157
|
+
This tool is designed to be lightweight and non-intrusive.
|
|
15022
15158
|
|
|
15023
|
-
|
|
15159
|
+
### Step 3: Interpret Results
|
|
15024
15160
|
|
|
15025
|
-
|
|
15161
|
+
The tool will return one of several possible outcomes:
|
|
15026
15162
|
|
|
15027
|
-
|
|
15163
|
+
#### New Vulnerabilities Detected
|
|
15028
15164
|
|
|
15029
|
-
|
|
15165
|
+
If new security issues are found:
|
|
15030
15166
|
|
|
15031
|
-
1. **
|
|
15032
|
-
|
|
15033
|
-
offset: 0
|
|
15034
|
-
\`\`\`
|
|
15167
|
+
1. **Alert the user promptly:**
|
|
15168
|
+
"\u26A0\uFE0F New security vulnerabilities detected!"
|
|
15035
15169
|
|
|
15036
|
-
2. **
|
|
15037
|
-
|
|
15038
|
-
|
|
15039
|
-
|
|
15040
|
-
\`\`\`
|
|
15170
|
+
2. **Provide summary:**
|
|
15171
|
+
- Number of new vulnerabilities
|
|
15172
|
+
- Severity breakdown
|
|
15173
|
+
- Files affected
|
|
15041
15174
|
|
|
15042
|
-
3. **
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
limit: ${totalCount}
|
|
15046
|
-
\`\`\`
|
|
15175
|
+
3. **Recommend immediate action:**
|
|
15176
|
+
- For Critical/High: "I recommend reviewing these immediately"
|
|
15177
|
+
- For Medium/Low: "These should be addressed when convenient"
|
|
15047
15178
|
|
|
15048
|
-
|
|
15179
|
+
4. **Offer next steps:**
|
|
15180
|
+
- "Would you like to scan and see the details?"
|
|
15181
|
+
- "Should I fetch the available fixes?"
|
|
15182
|
+
- Suggest calling \`scan_and_fix_vulnerabilities\` or \`fetch_available_fixes\`
|
|
15049
15183
|
|
|
15050
|
-
|
|
15184
|
+
#### No New Vulnerabilities
|
|
15051
15185
|
|
|
15052
|
-
|
|
15186
|
+
"\u2713 Monitoring active. No new security vulnerabilities detected."
|
|
15053
15187
|
|
|
15054
|
-
-
|
|
15055
|
-
-
|
|
15056
|
-
-
|
|
15188
|
+
Optional follow-up:
|
|
15189
|
+
- Confirm monitoring is now enabled
|
|
15190
|
+
- Mention that checks will continue periodically
|
|
15191
|
+
- Reassure the user their code remains secure
|
|
15057
15192
|
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15193
|
+
#### Monitoring Enabled
|
|
15194
|
+
|
|
15195
|
+
"\u2713 Continuous security monitoring has been enabled for this repository."
|
|
15196
|
+
|
|
15197
|
+
Explain what this means:
|
|
15198
|
+
- Periodic background checks will run
|
|
15199
|
+
- User will be notified of new vulnerabilities
|
|
15200
|
+
- No action required from user right now
|
|
15201
|
+
|
|
15202
|
+
### Step 4: Handle User Response
|
|
15203
|
+
|
|
15204
|
+
**If new vulnerabilities were found:**
|
|
15205
|
+
|
|
15206
|
+
Guide the user to take appropriate action:
|
|
15207
|
+
|
|
15208
|
+
1. **Immediate threats (Critical/High):**
|
|
15209
|
+
- Strongly recommend scanning now
|
|
15210
|
+
- Offer to fetch and display fixes
|
|
15211
|
+
- Suggest not committing until fixed
|
|
15212
|
+
|
|
15213
|
+
2. **Medium priority:**
|
|
15214
|
+
- Add to todo list or backlog
|
|
15215
|
+
- Schedule time to address
|
|
15216
|
+
- Can proceed with current work
|
|
15217
|
+
|
|
15218
|
+
3. **Low priority:**
|
|
15219
|
+
- Track for future maintenance
|
|
15220
|
+
- Can be addressed in next refactoring
|
|
15221
|
+
- No immediate action required
|
|
15222
|
+
|
|
15223
|
+
**If no issues found:**
|
|
15224
|
+
|
|
15225
|
+
- Congratulate the user on maintaining security
|
|
15226
|
+
- Remind them monitoring will continue
|
|
15227
|
+
- Suggest they can continue their work confidently
|
|
15228
|
+
|
|
15229
|
+
### Step 5: Integration into Workflow
|
|
15230
|
+
|
|
15231
|
+
This tool should be called **automatically** in certain scenarios:
|
|
15232
|
+
|
|
15233
|
+
1. **End-of-session cleanup:**
|
|
15234
|
+
After a user completes a significant amount of work
|
|
15235
|
+
|
|
15236
|
+
2. **Post-fix verification:**
|
|
15237
|
+
After applying security fixes to ensure no new issues
|
|
15238
|
+
|
|
15239
|
+
3. **Pre-commit hook simulation:**
|
|
15240
|
+
Before suggesting the user commit their changes
|
|
15241
|
+
|
|
15242
|
+
4. **Periodic checks:**
|
|
15243
|
+
During long-running IDE sessions (every 15-30 minutes)
|
|
15244
|
+
|
|
15245
|
+
## Best Practices
|
|
15246
|
+
|
|
15247
|
+
### DO:
|
|
15248
|
+
\u2713 Call this tool frequently and automatically
|
|
15249
|
+
\u2713 Make it part of your regular workflow
|
|
15250
|
+
\u2713 Alert users immediately when issues are found
|
|
15251
|
+
\u2713 Provide clear severity context
|
|
15252
|
+
\u2713 Offer actionable next steps
|
|
15253
|
+
\u2713 Keep the messaging positive and non-alarming
|
|
15254
|
+
|
|
15255
|
+
### DON'T:
|
|
15256
|
+
\u2717 Make this tool intrusive or annoying
|
|
15257
|
+
\u2717 Overwhelm users with constant notifications
|
|
15258
|
+
\u2717 Ignore Critical/High severity findings
|
|
15259
|
+
\u2717 Forget to explain what monitoring means
|
|
15260
|
+
\u2717 Skip this step at the end of sessions
|
|
15261
|
+
|
|
15262
|
+
## Monitoring vs. Scanning
|
|
15263
|
+
|
|
15264
|
+
It's important to understand the difference:
|
|
15265
|
+
|
|
15266
|
+
| Feature | check_for_new_available_fixes | scan_and_fix_vulnerabilities |
|
|
15267
|
+
|---------|------------------------------|------------------------------|
|
|
15268
|
+
| Purpose | Continuous monitoring | Full security scan |
|
|
15269
|
+
| Speed | Very fast | Slower (minutes) |
|
|
15270
|
+
| Depth | Lightweight check | Comprehensive analysis |
|
|
15271
|
+
| When | Frequently, automatically | On-demand, deliberately |
|
|
15272
|
+
| Results | Binary (new issues yes/no) | Detailed vulnerability reports |
|
|
15273
|
+
| Resource usage | Minimal | Higher |
|
|
15274
|
+
|
|
15275
|
+
**Strategy:** Use monitoring frequently, trigger full scans only when needed.
|
|
15276
|
+
|
|
15277
|
+
## Example Usage
|
|
15278
|
+
|
|
15279
|
+
### Scenario 1: End of Coding Session
|
|
15280
|
+
|
|
15281
|
+
\`\`\`
|
|
15282
|
+
AI: "I'm running a final security check on your changes..."
|
|
15283
|
+
|
|
15284
|
+
[Calls check_for_new_available_fixes]
|
|
15285
|
+
|
|
15286
|
+
AI: "\u2713 All clear! No new security vulnerabilities detected. Your code is safe to commit."
|
|
15287
|
+
\`\`\`
|
|
15288
|
+
|
|
15289
|
+
### Scenario 2: New Vulnerabilities Found
|
|
15290
|
+
|
|
15291
|
+
\`\`\`
|
|
15292
|
+
AI: "Running continuous security monitoring..."
|
|
15293
|
+
|
|
15294
|
+
[Calls check_for_new_available_fixes]
|
|
15295
|
+
|
|
15296
|
+
AI: "\u26A0\uFE0F I detected 2 new security vulnerabilities:
|
|
15297
|
+
- 1 High severity
|
|
15298
|
+
- 1 Medium severity
|
|
15299
|
+
|
|
15300
|
+
Would you like me to run a full scan to see the details and available fixes?"
|
|
15301
|
+
|
|
15302
|
+
User: "Yes, please"
|
|
15303
|
+
|
|
15304
|
+
[AI proceeds to call scan_and_fix_vulnerabilities]
|
|
15305
|
+
\`\`\`
|
|
15306
|
+
|
|
15307
|
+
### Scenario 3: After Applying Fixes
|
|
15308
|
+
|
|
15309
|
+
\`\`\`
|
|
15310
|
+
AI: "I've applied the security fixes. Let me verify no new issues were introduced..."
|
|
15311
|
+
|
|
15312
|
+
[Calls check_for_new_available_fixes]
|
|
15313
|
+
|
|
15314
|
+
AI: "\u2713 Perfect! The fixes resolved the issues and no new vulnerabilities were introduced. Your code is now more secure."
|
|
15315
|
+
\`\`\`
|
|
15316
|
+
|
|
15317
|
+
## Silent vs. Announced Monitoring
|
|
15318
|
+
|
|
15319
|
+
**Silent monitoring** (recommended for background checks):
|
|
15320
|
+
- Call the tool without announcing it
|
|
15321
|
+
- Only notify user if issues are found
|
|
15322
|
+
- Keeps the experience smooth and non-intrusive
|
|
15323
|
+
|
|
15324
|
+
**Announced monitoring** (use when setting up or after significant changes):
|
|
15325
|
+
- Tell the user monitoring is running
|
|
15326
|
+
- Confirm when monitoring is enabled
|
|
15327
|
+
- Provides transparency and confidence
|
|
15328
|
+
|
|
15329
|
+
## Technical Details
|
|
15330
|
+
|
|
15331
|
+
The tool:
|
|
15332
|
+
- Connects to Mobb's backend API
|
|
15333
|
+
- Checks for new vulnerability data
|
|
15334
|
+
- Compares against last known state
|
|
15335
|
+
- Returns summary of new findings
|
|
15336
|
+
- Maintains minimal overhead
|
|
15337
|
+
|
|
15338
|
+
## Ready to Monitor
|
|
15339
|
+
|
|
15340
|
+
Call the \`check_for_new_available_fixes\` tool now${args?.path ? ` for ${args.path}` : ""} to enable continuous security monitoring. This is a best practice that helps catch vulnerabilities early and maintain code security over time.
|
|
15341
|
+
`;
|
|
15342
|
+
return this.createUserMessage(promptText);
|
|
15343
|
+
}
|
|
15344
|
+
};
|
|
15345
|
+
|
|
15346
|
+
// src/mcp/prompts/FullSecurityAuditPrompt.ts
|
|
15347
|
+
import { z as z34 } from "zod";
|
|
15348
|
+
var FullSecurityAuditArgsSchema = z34.object({
|
|
15349
|
+
path: z34.string().optional()
|
|
15350
|
+
});
|
|
15351
|
+
var FullSecurityAuditPrompt = class extends BasePrompt {
|
|
15352
|
+
constructor() {
|
|
15353
|
+
super(...arguments);
|
|
15354
|
+
__publicField(this, "name", "full-security-audit");
|
|
15355
|
+
__publicField(this, "description", "Complete end-to-end security audit workflow: scan \u2192 review \u2192 fix \u2192 verify \u2192 monitor");
|
|
15356
|
+
__publicField(this, "arguments", [
|
|
15357
|
+
{
|
|
15358
|
+
name: "path",
|
|
15359
|
+
description: "Optional: Full local path to the git repository to audit",
|
|
15360
|
+
required: false
|
|
15361
|
+
}
|
|
15362
|
+
]);
|
|
15363
|
+
__publicField(this, "argumentsValidationSchema", FullSecurityAuditArgsSchema);
|
|
15364
|
+
}
|
|
15365
|
+
async generatePrompt(validatedArgs) {
|
|
15366
|
+
const args = validatedArgs;
|
|
15367
|
+
const promptText = `# Complete Security Audit Workflow
|
|
15368
|
+
|
|
15369
|
+
This is a comprehensive, end-to-end security audit process that will scan, review, fix, verify, and set up monitoring for a repository.
|
|
15370
|
+
|
|
15371
|
+
## Audit Overview
|
|
15372
|
+
|
|
15373
|
+
This workflow includes:
|
|
15374
|
+
1. **Initial Assessment** - Understand the repository
|
|
15375
|
+
2. **Comprehensive Scan** - Full security analysis
|
|
15376
|
+
3. **Issue Review** - Categorize and prioritize vulnerabilities
|
|
15377
|
+
4. **Fix Application** - Apply security patches systematically
|
|
15378
|
+
5. **Verification** - Confirm fixes work correctly
|
|
15379
|
+
6. **Continuous Monitoring** - Set up ongoing security checks
|
|
15380
|
+
7. **Final Report** - Document all actions taken
|
|
15381
|
+
|
|
15382
|
+
**Estimated Time:** 10-30 minutes depending on repository size and issue count
|
|
15383
|
+
|
|
15384
|
+
## Prerequisites
|
|
15385
|
+
|
|
15386
|
+
Before starting:
|
|
15387
|
+
- Repository should be in a clean git state (or user is aware of uncommitted changes)
|
|
15388
|
+
- Tests should be available and passing
|
|
15389
|
+
- User has time to review and address issues
|
|
15390
|
+
- Backup or branch created (recommended for first-time users)
|
|
15391
|
+
|
|
15392
|
+
## Phase 1: Initial Assessment
|
|
15393
|
+
|
|
15394
|
+
### Step 1.1: Gather Repository Information
|
|
15395
|
+
${args?.path ? `\u2713 Repository path: \`${args.path}\`` : `- Request repository path from user
|
|
15396
|
+
- Ask: "What is the full path to the repository you want to audit?"`}
|
|
15397
|
+
|
|
15398
|
+
### Step 1.2: Set Expectations
|
|
15399
|
+
|
|
15400
|
+
Inform the user:
|
|
15401
|
+
|
|
15402
|
+
\`\`\`
|
|
15403
|
+
"I'll perform a complete security audit of your repository. This will:
|
|
15404
|
+
- Scan all code for security vulnerabilities
|
|
15405
|
+
- Identify issues across all severity levels
|
|
15406
|
+
- Provide automatic fixes where possible
|
|
15407
|
+
- Set up continuous monitoring
|
|
15408
|
+
|
|
15409
|
+
This process will take a few minutes. I'll guide you through each step and explain my findings.
|
|
15410
|
+
|
|
15411
|
+
Ready to begin?"
|
|
15412
|
+
\`\`\`
|
|
15413
|
+
|
|
15414
|
+
### Step 1.3: Check Repository Status
|
|
15415
|
+
|
|
15416
|
+
Recommend running git status:
|
|
15417
|
+
\`\`\`bash
|
|
15418
|
+
git status
|
|
15419
|
+
\`\`\`
|
|
15420
|
+
|
|
15421
|
+
If there are uncommitted changes, suggest:
|
|
15422
|
+
- "I see uncommitted changes. Would you like to commit or stash them first?"
|
|
15423
|
+
- "We can proceed, but I recommend committing current work first."
|
|
15424
|
+
|
|
15425
|
+
## Phase 2: Comprehensive Scan
|
|
15426
|
+
|
|
15427
|
+
### Step 2.1: Initial Full Scan
|
|
15428
|
+
|
|
15429
|
+
Call \`scan_and_fix_vulnerabilities\`:
|
|
15430
|
+
|
|
15431
|
+
\`\`\`json
|
|
15432
|
+
{
|
|
15433
|
+
"path": "${args?.path || "<repository-path>"}",
|
|
15434
|
+
"limit": 10,
|
|
15435
|
+
"maxFiles": 50
|
|
15436
|
+
}
|
|
15437
|
+
\`\`\`
|
|
15438
|
+
|
|
15439
|
+
Larger limits for comprehensive audit.
|
|
15440
|
+
|
|
15441
|
+
### Step 2.2: Initial Results Analysis
|
|
15442
|
+
|
|
15443
|
+
When results arrive, analyze and present:
|
|
15444
|
+
|
|
15445
|
+
1. **Executive Summary:**
|
|
15446
|
+
\`\`\`
|
|
15447
|
+
Security Scan Complete
|
|
15448
|
+
----------------------
|
|
15449
|
+
Total Vulnerabilities Found: [N]
|
|
15450
|
+
|
|
15451
|
+
By Severity:
|
|
15452
|
+
- \u{1F534} Critical: [N] (immediate action required)
|
|
15453
|
+
- \u{1F7E0} High: [N] (urgent)
|
|
15454
|
+
- \u{1F7E1} Medium: [N] (important)
|
|
15455
|
+
- \u{1F535} Low: [N] (maintenance)
|
|
15456
|
+
|
|
15457
|
+
By Category:
|
|
15458
|
+
- [List top 3-5 vulnerability types found]
|
|
15459
|
+
|
|
15460
|
+
Fixable: [N] vulnerabilities have automatic fixes available
|
|
15461
|
+
\`\`\`
|
|
15462
|
+
|
|
15463
|
+
2. **Initial Recommendation:**
|
|
15464
|
+
Based on findings, recommend:
|
|
15465
|
+
- If Critical exists: "Address critical issues immediately"
|
|
15466
|
+
- If mostly High/Medium: "Systematic fix approach recommended"
|
|
15467
|
+
- If only Low: "Good security posture, minor improvements available"
|
|
15468
|
+
|
|
15469
|
+
## Phase 3: Issue Review & Prioritization
|
|
15470
|
+
|
|
15471
|
+
### Step 3.1: Detailed Issue Presentation
|
|
15472
|
+
|
|
15473
|
+
Present issues in priority order:
|
|
15474
|
+
|
|
15475
|
+
**For each Critical vulnerability:**
|
|
15476
|
+
\`\`\`
|
|
15477
|
+
\u{1F534} CRITICAL: [Type]
|
|
15478
|
+
Location: [file:line]
|
|
15479
|
+
Risk Level: Severe Security Threat
|
|
15480
|
+
|
|
15481
|
+
Description: [What the vulnerability is]
|
|
15482
|
+
Attack Vector: [How it could be exploited]
|
|
15483
|
+
Impact: [What an attacker could do]
|
|
15484
|
+
|
|
15485
|
+
Proposed Fix: [Summary of the fix]
|
|
15486
|
+
[Show diff/patch preview]
|
|
15487
|
+
|
|
15488
|
+
Last modified by: [git blame]
|
|
15489
|
+
\`\`\`
|
|
15490
|
+
|
|
15491
|
+
Continue for High, Medium, Low...
|
|
15492
|
+
|
|
15493
|
+
### Step 3.2: Create Fix Plan
|
|
15494
|
+
|
|
15495
|
+
Generate a structured fix plan:
|
|
15496
|
+
|
|
15497
|
+
\`\`\`markdown
|
|
15498
|
+
## Security Fix Plan
|
|
15499
|
+
|
|
15500
|
+
### Phase 1: Critical Fixes (Do First)
|
|
15501
|
+
1. [Vulnerability type] in [file]
|
|
15502
|
+
2. [Vulnerability type] in [file]
|
|
15503
|
+
...
|
|
15504
|
+
|
|
15505
|
+
### Phase 2: High Severity Fixes
|
|
15506
|
+
1. [Vulnerability type] in [file]
|
|
15507
|
+
2. [Vulnerability type] in [file]
|
|
15508
|
+
...
|
|
15509
|
+
|
|
15510
|
+
### Phase 3: Medium Severity Fixes
|
|
15511
|
+
[Can be done in follow-up session]
|
|
15512
|
+
|
|
15513
|
+
### Phase 4: Low Severity Fixes
|
|
15514
|
+
[Add to maintenance backlog]
|
|
15515
|
+
\`\`\`
|
|
15516
|
+
|
|
15517
|
+
### Step 3.3: Get User Approval
|
|
15518
|
+
|
|
15519
|
+
Ask user how they want to proceed:
|
|
15520
|
+
|
|
15521
|
+
"I've identified the security issues and created a fix plan. How would you like to proceed?
|
|
15522
|
+
|
|
15523
|
+
1. **Comprehensive Fix** - Fix all Critical and High issues now (recommended)
|
|
15524
|
+
2. **Critical Only** - Fix only Critical issues now
|
|
15525
|
+
3. **Selective Fix** - Review and choose which fixes to apply
|
|
15526
|
+
4. **Report Only** - Generate report without applying fixes (for review)
|
|
15527
|
+
|
|
15528
|
+
Recommendation: Option 1 for best security posture."
|
|
15529
|
+
|
|
15530
|
+
## Phase 4: Fix Application
|
|
15531
|
+
|
|
15532
|
+
Based on user choice, systematically apply fixes:
|
|
15533
|
+
|
|
15534
|
+
### Step 4.1: Apply Critical Fixes
|
|
15535
|
+
|
|
15536
|
+
For each Critical fix:
|
|
15537
|
+
1. Show what will be fixed
|
|
15538
|
+
2. Apply the patch
|
|
15539
|
+
3. Confirm application: "\u2713 Fixed: [vulnerability] in [file]"
|
|
15540
|
+
4. Track progress: "[N/Total] Critical fixes applied"
|
|
15541
|
+
|
|
15542
|
+
### Step 4.2: Apply High Severity Fixes
|
|
15543
|
+
|
|
15544
|
+
Same process as Critical, but can be done in batches.
|
|
15545
|
+
|
|
15546
|
+
### Step 4.3: Handle Fix Failures
|
|
15547
|
+
|
|
15548
|
+
If a fix fails to apply:
|
|
15549
|
+
1. Note the failure
|
|
15550
|
+
2. Show the conflict or error
|
|
15551
|
+
3. Mark for manual review
|
|
15552
|
+
4. Continue with remaining fixes
|
|
15553
|
+
5. Summarize failed fixes at the end
|
|
15554
|
+
|
|
15555
|
+
## Phase 5: Verification
|
|
15556
|
+
|
|
15557
|
+
### Step 5.1: Verify Patches Applied
|
|
15558
|
+
|
|
15559
|
+
Check each modified file:
|
|
15560
|
+
\`\`\`bash
|
|
15561
|
+
git status
|
|
15562
|
+
git diff
|
|
15563
|
+
\`\`\`
|
|
15564
|
+
|
|
15565
|
+
Confirm:
|
|
15566
|
+
- Expected files were modified
|
|
15567
|
+
- No unexpected changes
|
|
15568
|
+
- No merge conflicts
|
|
15569
|
+
|
|
15570
|
+
### Step 5.2: Run Test Suite
|
|
15571
|
+
|
|
15572
|
+
If tests exist:
|
|
15573
|
+
|
|
15574
|
+
\`\`\`bash
|
|
15575
|
+
# Run appropriate test command
|
|
15576
|
+
npm test
|
|
15577
|
+
# or
|
|
15578
|
+
pytest
|
|
15579
|
+
# or
|
|
15580
|
+
mvn test
|
|
15581
|
+
\`\`\`
|
|
15582
|
+
|
|
15583
|
+
**If tests pass:**
|
|
15584
|
+
"\u2705 All tests passed! Security fixes did not break functionality."
|
|
15585
|
+
|
|
15586
|
+
**If tests fail:**
|
|
15587
|
+
"\u26A0\uFE0F Some tests are failing after applying fixes:
|
|
15588
|
+
[List failing tests]
|
|
15589
|
+
|
|
15590
|
+
This could mean:
|
|
15591
|
+
1. Tests need to be updated (common for security fixes)
|
|
15592
|
+
2. A fix introduced an issue (less common)
|
|
15593
|
+
|
|
15594
|
+
Would you like me to:
|
|
15595
|
+
1. Review the failing tests
|
|
15596
|
+
2. Revert specific fixes
|
|
15597
|
+
3. Continue anyway (tests may need updates)"
|
|
15598
|
+
|
|
15599
|
+
### Step 5.3: Re-scan for Verification
|
|
15600
|
+
|
|
15601
|
+
Call \`scan_and_fix_vulnerabilities\` again with \`rescan: true\`:
|
|
15602
|
+
|
|
15603
|
+
\`\`\`json
|
|
15604
|
+
{
|
|
15605
|
+
"path": "${args?.path || "<repository-path>"}",
|
|
15606
|
+
"rescan": true,
|
|
15607
|
+
"limit": 10
|
|
15608
|
+
}
|
|
15609
|
+
\`\`\`
|
|
15610
|
+
|
|
15611
|
+
Compare before/after:
|
|
15612
|
+
- Confirm fixed vulnerabilities are gone
|
|
15613
|
+
- Check no new vulnerabilities were introduced
|
|
15614
|
+
- Verify severity counts decreased as expected
|
|
15615
|
+
|
|
15616
|
+
## Phase 6: Continuous Monitoring Setup
|
|
15617
|
+
|
|
15618
|
+
### Step 6.1: Enable Monitoring
|
|
15619
|
+
|
|
15620
|
+
Call \`check_for_new_available_fixes\`:
|
|
15621
|
+
|
|
15622
|
+
\`\`\`json
|
|
15623
|
+
{
|
|
15624
|
+
"path": "${args?.path || "<repository-path>"}"
|
|
15625
|
+
}
|
|
15626
|
+
\`\`\`
|
|
15627
|
+
|
|
15628
|
+
### Step 6.2: Explain Monitoring
|
|
15629
|
+
|
|
15630
|
+
"\u2705 Continuous security monitoring is now enabled for this repository.
|
|
15631
|
+
|
|
15632
|
+
What this means:
|
|
15633
|
+
- Periodic background checks for new vulnerabilities
|
|
15634
|
+
- Notifications when security issues are detected
|
|
15635
|
+
- Ongoing protection as code evolves
|
|
15636
|
+
|
|
15637
|
+
This helps maintain the security improvements we just made."
|
|
15638
|
+
|
|
15639
|
+
## Phase 7: Final Report
|
|
15640
|
+
|
|
15641
|
+
### Step 7.1: Generate Comprehensive Report
|
|
15642
|
+
|
|
15643
|
+
Create a detailed report:
|
|
15644
|
+
|
|
15645
|
+
\`\`\`markdown
|
|
15646
|
+
# Security Audit Report
|
|
15647
|
+
Repository: [name/path]
|
|
15648
|
+
Date: [date]
|
|
15649
|
+
Audited by: Mobb AI Security Assistant
|
|
15650
|
+
|
|
15651
|
+
## Executive Summary
|
|
15652
|
+
- Total vulnerabilities found: [N]
|
|
15653
|
+
- Vulnerabilities fixed: [N]
|
|
15654
|
+
- Files modified: [N]
|
|
15655
|
+
- Test status: [Pass/Fail/Not Run]
|
|
15656
|
+
|
|
15657
|
+
## Vulnerabilities Fixed
|
|
15658
|
+
|
|
15659
|
+
### Critical (\u{1F534})
|
|
15660
|
+
1. [Type] in [file:line] - FIXED \u2705
|
|
15661
|
+
- Risk: [description]
|
|
15662
|
+
- Fix: [description]
|
|
15663
|
+
|
|
15664
|
+
2. [Type] in [file:line] - FIXED \u2705
|
|
15665
|
+
...
|
|
15666
|
+
|
|
15667
|
+
### High (\u{1F7E0})
|
|
15668
|
+
[Similar format]
|
|
15669
|
+
|
|
15670
|
+
### Medium (\u{1F7E1})
|
|
15671
|
+
[List - note which were fixed]
|
|
15672
|
+
|
|
15673
|
+
### Low (\u{1F535})
|
|
15674
|
+
[List - note which were fixed]
|
|
15675
|
+
|
|
15676
|
+
## Files Modified
|
|
15677
|
+
- [list all modified files with change descriptions]
|
|
15678
|
+
|
|
15679
|
+
## Verification Results
|
|
15680
|
+
\u2705 All fixes applied successfully
|
|
15681
|
+
\u2705 Tests passing
|
|
15682
|
+
\u2705 Re-scan confirms vulnerabilities resolved
|
|
15683
|
+
\u2705 No new vulnerabilities introduced
|
|
15684
|
+
|
|
15685
|
+
## Remaining Items
|
|
15686
|
+
- [N] Medium severity issues (recommended to fix soon)
|
|
15687
|
+
- [N] Low severity issues (maintenance backlog)
|
|
15688
|
+
|
|
15689
|
+
## Recommendations
|
|
15690
|
+
1. Commit these security improvements
|
|
15691
|
+
2. Deploy to staging environment for testing
|
|
15692
|
+
3. Schedule follow-up for remaining Medium issues
|
|
15693
|
+
4. Review security practices to prevent future issues
|
|
15694
|
+
5. Keep continuous monitoring enabled
|
|
15695
|
+
|
|
15696
|
+
## Next Steps
|
|
15697
|
+
1. Review the changes: git diff
|
|
15698
|
+
2. Run additional tests if needed
|
|
15699
|
+
3. Commit: git add . && git commit -m "Security fixes: addressed [N] critical and high severity vulnerabilities"
|
|
15700
|
+
4. Push to remote repository
|
|
15701
|
+
5. Deploy with confidence
|
|
15702
|
+
|
|
15703
|
+
---
|
|
15704
|
+
\u{1F512} Security Level: [Excellent/Good/Fair] (based on remaining issues)
|
|
15705
|
+
\`\`\`
|
|
15706
|
+
|
|
15707
|
+
### Step 7.2: Provide Next Steps
|
|
15708
|
+
|
|
15709
|
+
Give clear guidance:
|
|
15710
|
+
|
|
15711
|
+
"## What to do next:
|
|
15712
|
+
|
|
15713
|
+
**Immediate (Do now):**
|
|
15714
|
+
1. Review the changes made (git diff)
|
|
15715
|
+
2. Commit the security fixes
|
|
15716
|
+
3. Push to your repository
|
|
15717
|
+
|
|
15718
|
+
**Soon (This week):**
|
|
15719
|
+
1. Address remaining Medium severity issues ([N] items)
|
|
15720
|
+
2. Review security best practices for your framework
|
|
15721
|
+
3. Share this report with your team
|
|
15722
|
+
|
|
15723
|
+
**Ongoing:**
|
|
15724
|
+
1. Continuous monitoring is active
|
|
15725
|
+
2. Run security scans after major changes
|
|
15726
|
+
3. Keep dependencies updated
|
|
15727
|
+
|
|
15728
|
+
**Questions?**
|
|
15729
|
+
- Need help with any specific fix?
|
|
15730
|
+
- Want to understand a vulnerability better?
|
|
15731
|
+
- Need guidance on preventing similar issues?
|
|
15732
|
+
|
|
15733
|
+
Ask me anything!"
|
|
15734
|
+
|
|
15735
|
+
## Important Guidelines
|
|
15736
|
+
|
|
15737
|
+
### Communication Throughout
|
|
15738
|
+
|
|
15739
|
+
**Be:**
|
|
15740
|
+
- Professional and clear
|
|
15741
|
+
- Patient and thorough
|
|
15742
|
+
- Encouraging and supportive
|
|
15743
|
+
- Transparent about what you're doing
|
|
15744
|
+
|
|
15745
|
+
**Tone:**
|
|
15746
|
+
- Security issues are serious but fixable
|
|
15747
|
+
- Congratulate progress
|
|
15748
|
+
- Celebrate improvements
|
|
15749
|
+
- Don't blame or shame
|
|
15750
|
+
|
|
15751
|
+
### DO:
|
|
15752
|
+
\u2705 Follow all phases systematically
|
|
15753
|
+
\u2705 Explain each step clearly
|
|
15754
|
+
\u2705 Get user approval before major actions
|
|
15755
|
+
\u2705 Verify all changes
|
|
15756
|
+
\u2705 Provide comprehensive documentation
|
|
15757
|
+
\u2705 Enable monitoring
|
|
15758
|
+
\u2705 Give clear next steps
|
|
15759
|
+
|
|
15760
|
+
### DON'T:
|
|
15761
|
+
\u274C Rush through the process
|
|
15762
|
+
\u274C Skip verification steps
|
|
15763
|
+
\u274C Apply fixes without explanation
|
|
15764
|
+
\u274C Forget to check for new issues
|
|
15765
|
+
\u274C Leave user without next steps
|
|
15766
|
+
\u274C Create alarm - be solution-focused
|
|
15767
|
+
|
|
15768
|
+
## Time Management
|
|
15769
|
+
|
|
15770
|
+
For large repositories with many issues:
|
|
15771
|
+
- Take breaks between phases
|
|
15772
|
+
- Offer to pause and resume later
|
|
15773
|
+
- Batch fixes appropriately
|
|
15774
|
+
- Don't overwhelm the user
|
|
15775
|
+
|
|
15776
|
+
Suggest: "We've fixed [N] critical issues. Would you like to continue with High severity, or take a break and resume later?"
|
|
15777
|
+
|
|
15778
|
+
## Success Criteria
|
|
15779
|
+
|
|
15780
|
+
Audit is successful when:
|
|
15781
|
+
\u2705 All Critical vulnerabilities are fixed
|
|
15782
|
+
\u2705 Most High severity issues addressed
|
|
15783
|
+
\u2705 All fixes verified and tested
|
|
15784
|
+
\u2705 No new vulnerabilities introduced
|
|
15785
|
+
\u2705 Continuous monitoring enabled
|
|
15786
|
+
\u2705 Comprehensive report provided
|
|
15787
|
+
\u2705 User understands next steps
|
|
15788
|
+
|
|
15789
|
+
## Ready to Begin
|
|
15790
|
+
|
|
15791
|
+
This is a comprehensive security audit that will significantly improve the security posture of the repository. Follow each phase carefully, communicate clearly, and celebrate the improvements made.
|
|
15792
|
+
|
|
15793
|
+
Begin the audit now${args?.path ? ` for ${args.path}` : ""}.
|
|
15794
|
+
`;
|
|
15795
|
+
return this.createUserMessage(promptText);
|
|
15796
|
+
}
|
|
15797
|
+
};
|
|
15798
|
+
|
|
15799
|
+
// src/mcp/prompts/ReviewAndFixCriticalPrompt.ts
|
|
15800
|
+
import { z as z35 } from "zod";
|
|
15801
|
+
var ReviewAndFixCriticalArgsSchema = z35.object({
|
|
15802
|
+
path: z35.string().optional()
|
|
15803
|
+
});
|
|
15804
|
+
var ReviewAndFixCriticalPrompt = class extends BasePrompt {
|
|
15805
|
+
constructor() {
|
|
15806
|
+
super(...arguments);
|
|
15807
|
+
__publicField(this, "name", "review-and-fix-critical");
|
|
15808
|
+
__publicField(this, "description", "Focused workflow for identifying and fixing Critical and High severity security vulnerabilities");
|
|
15809
|
+
__publicField(this, "arguments", [
|
|
15810
|
+
{
|
|
15811
|
+
name: "path",
|
|
15812
|
+
description: "Optional: Full local path to the git repository to scan and fix",
|
|
15813
|
+
required: false
|
|
15814
|
+
}
|
|
15815
|
+
]);
|
|
15816
|
+
__publicField(this, "argumentsValidationSchema", ReviewAndFixCriticalArgsSchema);
|
|
15817
|
+
}
|
|
15818
|
+
async generatePrompt(validatedArgs) {
|
|
15819
|
+
const args = validatedArgs;
|
|
15820
|
+
const promptText = `# Critical Security Vulnerabilities - Review and Fix
|
|
15821
|
+
|
|
15822
|
+
This is a focused workflow for identifying and addressing Critical and High severity security vulnerabilities that require immediate attention.
|
|
15823
|
+
|
|
15824
|
+
## Workflow Purpose
|
|
15825
|
+
|
|
15826
|
+
Use this workflow when:
|
|
15827
|
+
- Security is a high priority
|
|
15828
|
+
- Preparing for production deployment
|
|
15829
|
+
- Security audit or compliance review is needed
|
|
15830
|
+
- You want to address the most severe issues first
|
|
15831
|
+
- Time is limited and you need to focus on critical threats
|
|
15832
|
+
|
|
15833
|
+
## Severity Priority
|
|
15834
|
+
|
|
15835
|
+
**CRITICAL** \u{1F534}
|
|
15836
|
+
- Immediate security risk
|
|
15837
|
+
- Can lead to complete system compromise
|
|
15838
|
+
- Examples: Remote Code Execution, Authentication Bypass, SQL Injection with data exposure
|
|
15839
|
+
- **Action: FIX IMMEDIATELY**
|
|
15840
|
+
|
|
15841
|
+
**HIGH** \u{1F7E0}
|
|
15842
|
+
- Significant security vulnerability
|
|
15843
|
+
- Can lead to data breaches or unauthorized access
|
|
15844
|
+
- Examples: XSS attacks, Privilege Escalation, Exposed Sensitive Data
|
|
15845
|
+
- **Action: FIX URGENTLY**
|
|
15846
|
+
|
|
15847
|
+
Medium and Low severity issues will be noted but not prioritized in this workflow.
|
|
15848
|
+
|
|
15849
|
+
## Workflow Steps
|
|
15850
|
+
|
|
15851
|
+
### Step 1: Initial Scan
|
|
15852
|
+
${args?.path ? `Scanning repository at: \`${args.path}\`` : `Obtain the repository path from the user.`}
|
|
15853
|
+
|
|
15854
|
+
Call \`scan_and_fix_vulnerabilities\`:
|
|
15855
|
+
|
|
15856
|
+
\`\`\`json
|
|
15857
|
+
{
|
|
15858
|
+
"path": "${args?.path || "<repository-path>"}",
|
|
15859
|
+
"limit": 10,
|
|
15860
|
+
"maxFiles": 20
|
|
15861
|
+
}
|
|
15862
|
+
\`\`\`
|
|
15863
|
+
|
|
15864
|
+
Higher limits to ensure we catch all critical issues.
|
|
15865
|
+
|
|
15866
|
+
### Step 2: Filter and Present Critical Issues
|
|
15867
|
+
|
|
15868
|
+
When results arrive:
|
|
15869
|
+
|
|
15870
|
+
1. **Count vulnerabilities by severity:**
|
|
15871
|
+
- Critical count
|
|
15872
|
+
- High count
|
|
15873
|
+
- Medium count (mention but don't focus)
|
|
15874
|
+
- Low count (mention but don't focus)
|
|
15875
|
+
|
|
15876
|
+
2. **Present ONLY Critical and High severity issues:**
|
|
15877
|
+
|
|
15878
|
+
For each Critical/High vulnerability:
|
|
15879
|
+
|
|
15880
|
+
\`\`\`
|
|
15881
|
+
\u{1F534} CRITICAL: [Vulnerability Type]
|
|
15882
|
+
|
|
15883
|
+
File: [path/to/file.ext:line]
|
|
15884
|
+
Last modified by: [git blame user]
|
|
15885
|
+
|
|
15886
|
+
Risk: [Explain the security risk in simple terms]
|
|
15887
|
+
|
|
15888
|
+
Proposed Fix:
|
|
15889
|
+
[Show the diff/patch]
|
|
15890
|
+
|
|
15891
|
+
Impact: [What this fix does and why it's necessary]
|
|
15892
|
+
\`\`\`
|
|
15893
|
+
|
|
15894
|
+
3. **Provide clear summary:**
|
|
15895
|
+
"Found X critical and Y high severity vulnerabilities that require immediate attention."
|
|
15896
|
+
|
|
15897
|
+
### Step 3: Prioritize Fixes
|
|
15898
|
+
|
|
15899
|
+
Create a fix priority list:
|
|
15900
|
+
|
|
15901
|
+
**Phase 1 - Critical (DO FIRST):**
|
|
15902
|
+
- List all Critical issues
|
|
15903
|
+
- Sort by risk level
|
|
15904
|
+
- Recommend fixing ALL before any High issues
|
|
15905
|
+
|
|
15906
|
+
**Phase 2 - High (DO SECOND):**
|
|
15907
|
+
- List all High issues
|
|
15908
|
+
- Can be addressed after Critical are resolved
|
|
15909
|
+
|
|
15910
|
+
**Ask the user:**
|
|
15911
|
+
"I recommend we fix these in priority order. Would you like me to:
|
|
15912
|
+
1. Apply ALL critical fixes automatically (recommended)
|
|
15913
|
+
2. Review each critical fix individually
|
|
15914
|
+
3. See the full details before proceeding"
|
|
15915
|
+
|
|
15916
|
+
### Step 4: Apply Fixes
|
|
15917
|
+
|
|
15918
|
+
Based on user choice:
|
|
15919
|
+
|
|
15920
|
+
#### Option 1: Apply All Critical Automatically
|
|
15921
|
+
|
|
15922
|
+
\`\`\`
|
|
15923
|
+
"I'll apply all [N] critical fixes now. This will modify [X] files."
|
|
15924
|
+
|
|
15925
|
+
For each fix:
|
|
15926
|
+
1. Apply the patch
|
|
15927
|
+
2. Verify it applied successfully
|
|
15928
|
+
3. Show brief confirmation: "\u2713 Fixed: [vulnerability type] in [file]"
|
|
15929
|
+
|
|
15930
|
+
"All critical fixes applied. Running verification..."
|
|
15931
|
+
[Call check_for_new_available_fixes to verify]
|
|
15932
|
+
|
|
15933
|
+
"Next, I can address the [N] high severity issues. Continue?"
|
|
15934
|
+
\`\`\`
|
|
15935
|
+
|
|
15936
|
+
#### Option 2: Review Each Fix Individually
|
|
15937
|
+
|
|
15938
|
+
For each Critical fix:
|
|
15939
|
+
1. Show the vulnerability details
|
|
15940
|
+
2. Show the exact code changes
|
|
15941
|
+
3. Explain the security improvement
|
|
15942
|
+
4. Ask: "Apply this fix? (yes/no/skip)"
|
|
15943
|
+
5. Apply if approved
|
|
15944
|
+
6. Move to next
|
|
15945
|
+
|
|
15946
|
+
#### Option 3: Provide Full Details First
|
|
15947
|
+
|
|
15948
|
+
- Show comprehensive analysis of each vulnerability
|
|
15949
|
+
- Include CVE references if available
|
|
15950
|
+
- Explain attack vectors
|
|
15951
|
+
- Demonstrate how the fix prevents the attack
|
|
15952
|
+
- Then proceed to fixing phase
|
|
15953
|
+
|
|
15954
|
+
### Step 5: Verification
|
|
15955
|
+
|
|
15956
|
+
After applying fixes:
|
|
15957
|
+
|
|
15958
|
+
1. **Verify fixes applied correctly:**
|
|
15959
|
+
- Check files were modified
|
|
15960
|
+
- No merge conflicts
|
|
15961
|
+
- Code syntax is valid
|
|
15962
|
+
|
|
15963
|
+
2. **Run tests if available:**
|
|
15964
|
+
\`\`\`bash
|
|
15965
|
+
npm test
|
|
15966
|
+
# or
|
|
15967
|
+
pytest
|
|
15968
|
+
# or appropriate test command
|
|
15969
|
+
\`\`\`
|
|
15970
|
+
|
|
15971
|
+
3. **Re-scan to confirm:**
|
|
15972
|
+
Call \`scan_and_fix_vulnerabilities\` again with \`rescan: true\`
|
|
15973
|
+
|
|
15974
|
+
Verify:
|
|
15975
|
+
- Critical issues are resolved
|
|
15976
|
+
- No new issues were introduced
|
|
15977
|
+
- High severity count decreased (if those were also fixed)
|
|
15978
|
+
|
|
15979
|
+
### Step 6: Summary Report
|
|
15980
|
+
|
|
15981
|
+
Provide a comprehensive summary:
|
|
15982
|
+
|
|
15983
|
+
\`\`\`markdown
|
|
15984
|
+
## Security Fix Summary
|
|
15985
|
+
|
|
15986
|
+
### Fixed
|
|
15987
|
+
- \u2705 [N] Critical vulnerabilities resolved
|
|
15988
|
+
- \u2705 [N] High severity vulnerabilities resolved
|
|
15989
|
+
|
|
15990
|
+
### Files Modified
|
|
15991
|
+
- [list of modified files]
|
|
15992
|
+
|
|
15993
|
+
### Remaining Issues
|
|
15994
|
+
- \u26A0\uFE0F [N] Medium severity (can be addressed later)
|
|
15995
|
+
- \u2139\uFE0F [N] Low severity (maintenance backlog)
|
|
15996
|
+
|
|
15997
|
+
### Recommendations
|
|
15998
|
+
1. Run your test suite to ensure functionality
|
|
15999
|
+
2. Review the changes before committing
|
|
16000
|
+
3. Consider addressing remaining High severity issues
|
|
16001
|
+
4. Schedule time for Medium/Low issues
|
|
16002
|
+
5. Enable continuous monitoring
|
|
16003
|
+
|
|
16004
|
+
### Next Steps
|
|
16005
|
+
- Commit these security fixes
|
|
16006
|
+
- Deploy to staging for testing
|
|
16007
|
+
- Schedule follow-up for remaining issues
|
|
16008
|
+
\`\`\`
|
|
16009
|
+
|
|
16010
|
+
## Important Guidelines
|
|
16011
|
+
|
|
16012
|
+
### Communication Style
|
|
16013
|
+
|
|
16014
|
+
**For Critical Issues:**
|
|
16015
|
+
- Use urgent but calm language
|
|
16016
|
+
- Clearly explain the risk
|
|
16017
|
+
- Don't create panic, but convey seriousness
|
|
16018
|
+
- Be direct about the need to fix immediately
|
|
16019
|
+
|
|
16020
|
+
**For High Issues:**
|
|
16021
|
+
- Emphasize importance but not emergency
|
|
16022
|
+
- Explain impact on security posture
|
|
16023
|
+
- Recommend fixing soon but not necessarily right now
|
|
16024
|
+
|
|
16025
|
+
### DO:
|
|
16026
|
+
\u2705 Fix ALL Critical issues before moving to High
|
|
16027
|
+
\u2705 Explain each vulnerability clearly
|
|
16028
|
+
\u2705 Show exact code changes
|
|
16029
|
+
\u2705 Verify fixes were applied successfully
|
|
16030
|
+
\u2705 Run tests after applying fixes
|
|
16031
|
+
\u2705 Create a clear summary of actions taken
|
|
16032
|
+
\u2705 Recommend continuous monitoring
|
|
16033
|
+
|
|
16034
|
+
### DON'T:
|
|
16035
|
+
\u274C Apply fixes without user approval (except if explicitly requested)
|
|
16036
|
+
\u274C Minimize the importance of Critical issues
|
|
16037
|
+
\u274C Get distracted by Medium/Low issues during this workflow
|
|
16038
|
+
\u274C Skip verification steps
|
|
16039
|
+
\u274C Forget to check for new issues after applying fixes
|
|
16040
|
+
\u274C Rush through explanations
|
|
16041
|
+
|
|
16042
|
+
## Example Interaction
|
|
16043
|
+
|
|
16044
|
+
\`\`\`
|
|
16045
|
+
AI: "Scanning repository for critical security vulnerabilities..."
|
|
16046
|
+
|
|
16047
|
+
[Scans]
|
|
16048
|
+
|
|
16049
|
+
AI: "\u26A0\uFE0F **Security Alert: Critical Issues Found**
|
|
16050
|
+
|
|
16051
|
+
I found 3 critical and 5 high severity vulnerabilities:
|
|
16052
|
+
|
|
16053
|
+
\u{1F534} **CRITICAL ISSUES** (Must fix immediately):
|
|
16054
|
+
|
|
16055
|
+
1. **SQL Injection** in src/api/users.ts:67
|
|
16056
|
+
- Risk: Attacker can access entire database
|
|
16057
|
+
- Last modified by: john@example.com
|
|
16058
|
+
- Fix: Use parameterized queries
|
|
16059
|
+
|
|
16060
|
+
2. **Authentication Bypass** in src/auth/middleware.ts:23
|
|
16061
|
+
- Risk: Unauthorized access to admin functions
|
|
16062
|
+
- Last modified by: jane@example.com
|
|
16063
|
+
- Fix: Validate JWT signature properly
|
|
16064
|
+
|
|
16065
|
+
3. **Remote Code Execution** in src/utils/processor.ts:45
|
|
16066
|
+
- Risk: Attacker can execute arbitrary code on server
|
|
16067
|
+
- Last modified by: bob@example.com
|
|
16068
|
+
- Fix: Sanitize eval() input
|
|
16069
|
+
|
|
16070
|
+
\u{1F7E0} **HIGH SEVERITY** (Fix urgently):
|
|
16071
|
+
[Lists 5 high issues...]
|
|
16072
|
+
|
|
16073
|
+
**Recommendation:** Fix all 3 critical issues immediately. Would you like me to:
|
|
16074
|
+
1. Apply ALL critical fixes now (recommended) \u2190 [DEFAULT]
|
|
16075
|
+
2. Review each fix individually
|
|
16076
|
+
3. See detailed analysis first"
|
|
16077
|
+
|
|
16078
|
+
User: "Apply all critical fixes"
|
|
16079
|
+
|
|
16080
|
+
AI: "Applying all critical fixes...
|
|
16081
|
+
|
|
16082
|
+
\u2713 Fixed: SQL Injection in src/api/users.ts
|
|
16083
|
+
\u2713 Fixed: Authentication Bypass in src/auth/middleware.ts
|
|
16084
|
+
\u2713 Fixed: Remote Code Execution in src/utils/processor.ts
|
|
16085
|
+
|
|
16086
|
+
All critical vulnerabilities resolved! Running verification...
|
|
16087
|
+
|
|
16088
|
+
\u2713 Verification complete - no new issues introduced.
|
|
16089
|
+
|
|
16090
|
+
3 files modified, 0 critical issues remaining.
|
|
16091
|
+
|
|
16092
|
+
Would you like to proceed with fixing the 5 high severity issues?"
|
|
16093
|
+
\`\`\`
|
|
16094
|
+
|
|
16095
|
+
## Ready to Begin
|
|
16096
|
+
|
|
16097
|
+
This workflow focuses exclusively on the most dangerous vulnerabilities. Follow the steps above to systematically eliminate critical security threats from the codebase.
|
|
16098
|
+
|
|
16099
|
+
Start by scanning${args?.path ? ` ${args.path}` : " the repository"} and prioritizing Critical and High severity issues.
|
|
16100
|
+
`;
|
|
16101
|
+
return this.createUserMessage(promptText);
|
|
16102
|
+
}
|
|
16103
|
+
};
|
|
16104
|
+
|
|
16105
|
+
// src/mcp/prompts/ScanRecentChangesPrompt.ts
|
|
16106
|
+
import { z as z36 } from "zod";
|
|
16107
|
+
var ScanRecentChangesArgsSchema = z36.object({
|
|
16108
|
+
path: z36.string().optional()
|
|
16109
|
+
});
|
|
16110
|
+
var ScanRecentChangesPrompt = class extends BasePrompt {
|
|
16111
|
+
constructor() {
|
|
16112
|
+
super(...arguments);
|
|
16113
|
+
__publicField(this, "name", "scan-recent-changes");
|
|
16114
|
+
__publicField(this, "description", "Guide for scanning only recently modified files for new security vulnerabilities");
|
|
16115
|
+
__publicField(this, "arguments", [
|
|
16116
|
+
{
|
|
16117
|
+
name: "path",
|
|
16118
|
+
description: "Optional: Full local path to the git repository to scan",
|
|
16119
|
+
required: false
|
|
16120
|
+
}
|
|
16121
|
+
]);
|
|
16122
|
+
__publicField(this, "argumentsValidationSchema", ScanRecentChangesArgsSchema);
|
|
16123
|
+
}
|
|
16124
|
+
async generatePrompt(validatedArgs) {
|
|
16125
|
+
const args = validatedArgs;
|
|
16126
|
+
const promptText = `# Scan Recent Changes for Security Issues
|
|
16127
|
+
|
|
16128
|
+
This workflow helps you quickly scan only the files that have been recently modified, making security checks fast and targeted.
|
|
16129
|
+
|
|
16130
|
+
## When to Use This Workflow
|
|
16131
|
+
|
|
16132
|
+
Use this approach when:
|
|
16133
|
+
- You've just made code changes and want to check for new vulnerabilities
|
|
16134
|
+
- You want a quick security check without scanning the entire repository
|
|
16135
|
+
- You're working in a specific area of the codebase
|
|
16136
|
+
- You want faster scan results
|
|
16137
|
+
- You're doing iterative development and want continuous security feedback
|
|
16138
|
+
|
|
16139
|
+
## Workflow Steps
|
|
16140
|
+
|
|
16141
|
+
### Step 1: Determine Repository Path
|
|
16142
|
+
${args?.path ? `\u2713 Repository path provided: \`${args.path}\`` : `Ask the user for the full local path to the git repository.`}
|
|
16143
|
+
|
|
16144
|
+
### Step 2: Call scan_and_fix_vulnerabilities with Recent Changes Flag
|
|
16145
|
+
|
|
16146
|
+
Use the \`scan_and_fix_vulnerabilities\` tool with the \`scanRecentlyChangedFiles\` parameter:
|
|
16147
|
+
|
|
16148
|
+
\`\`\`json
|
|
16149
|
+
{
|
|
16150
|
+
"path": "${args?.path || "<repository-path>"}",
|
|
16151
|
+
"scanRecentlyChangedFiles": true,
|
|
16152
|
+
"limit": 5
|
|
16153
|
+
}
|
|
16154
|
+
\`\`\`
|
|
16155
|
+
|
|
16156
|
+
**Key parameters:**
|
|
16157
|
+
- \`scanRecentlyChangedFiles: true\` - Only scans files modified recently
|
|
16158
|
+
- \`limit: 5\` - Return up to 5 fixes (adjustable based on user needs)
|
|
16159
|
+
|
|
16160
|
+
### Step 3: Present Results
|
|
16161
|
+
|
|
16162
|
+
When you receive results:
|
|
16163
|
+
|
|
16164
|
+
#### If new vulnerabilities found:
|
|
16165
|
+
|
|
16166
|
+
1. **Alert the user:**
|
|
16167
|
+
"\u26A0\uFE0F Security issues detected in recently modified files!"
|
|
16168
|
+
|
|
16169
|
+
2. **Provide context:**
|
|
16170
|
+
- Number of new vulnerabilities introduced
|
|
16171
|
+
- Which files are affected
|
|
16172
|
+
- Severity breakdown
|
|
16173
|
+
- Who made the changes (git blame)
|
|
16174
|
+
|
|
16175
|
+
3. **Show each vulnerability:**
|
|
16176
|
+
- File and line number
|
|
16177
|
+
- Type of vulnerability
|
|
16178
|
+
- Severity level
|
|
16179
|
+
- Proposed fix with diff preview
|
|
16180
|
+
|
|
16181
|
+
4. **Recommend immediate action:**
|
|
16182
|
+
For Critical/High severity:
|
|
16183
|
+
- "I strongly recommend addressing these issues before committing/merging"
|
|
16184
|
+
- "Would you like me to apply the fixes now?"
|
|
16185
|
+
|
|
16186
|
+
#### If no vulnerabilities found:
|
|
16187
|
+
|
|
16188
|
+
"\u2713 Great! No new security issues detected in your recent changes."
|
|
16189
|
+
|
|
16190
|
+
Optional suggestions:
|
|
16191
|
+
- Continue with your work
|
|
16192
|
+
- Commit your changes
|
|
16193
|
+
- Consider enabling continuous monitoring
|
|
16194
|
+
|
|
16195
|
+
#### If no recently changed files:
|
|
16196
|
+
|
|
16197
|
+
"No recently modified files detected. This could mean:
|
|
16198
|
+
- No uncommitted changes exist
|
|
16199
|
+
- No files were modified recently
|
|
16200
|
+
- The repository has no git history
|
|
16201
|
+
|
|
16202
|
+
Would you like to:
|
|
16203
|
+
1. Perform a full repository scan instead?
|
|
16204
|
+
2. Check the repository status?"
|
|
16205
|
+
|
|
16206
|
+
### Step 4: Handle User Decisions
|
|
16207
|
+
|
|
16208
|
+
**If user wants to apply fixes:**
|
|
16209
|
+
- Confirm each fix before applying
|
|
16210
|
+
- Show the exact changes
|
|
16211
|
+
- Apply patches sequentially
|
|
16212
|
+
- Verify each application succeeded
|
|
16213
|
+
- Run tests if available
|
|
16214
|
+
|
|
16215
|
+
**If user wants to see more details:**
|
|
16216
|
+
- Explain the vulnerability type
|
|
16217
|
+
- Show the vulnerable code pattern
|
|
16218
|
+
- Explain how the fix improves security
|
|
16219
|
+
- Provide references or documentation links
|
|
16220
|
+
|
|
16221
|
+
**If user wants to continue without fixing:**
|
|
16222
|
+
- Warn about the risks (especially for Critical/High)
|
|
16223
|
+
- Suggest creating an issue to track the vulnerability
|
|
16224
|
+
- Remind them to fix before merging to production
|
|
16225
|
+
|
|
16226
|
+
### Step 5: Post-Scan Recommendations
|
|
16227
|
+
|
|
16228
|
+
After handling vulnerabilities:
|
|
16229
|
+
|
|
16230
|
+
1. **If fixes were applied:**
|
|
16231
|
+
- Verify the code still works (run tests)
|
|
16232
|
+
- Review the changes
|
|
16233
|
+
- Update commit message to mention security fixes
|
|
16234
|
+
- Consider running a full scan to check for other issues
|
|
16235
|
+
|
|
16236
|
+
2. **If fixes were deferred:**
|
|
16237
|
+
- Create tracking issues for the vulnerabilities
|
|
16238
|
+
- Add TODO comments in the code
|
|
16239
|
+
- Schedule time to address them
|
|
16240
|
+
|
|
16241
|
+
3. **Enable continuous monitoring:**
|
|
16242
|
+
Call \`check_for_new_available_fixes\`:
|
|
16243
|
+
\`\`\`json
|
|
16244
|
+
{
|
|
16245
|
+
"path": "${args?.path || "<repository-path>"}"
|
|
16246
|
+
}
|
|
16247
|
+
\`\`\`
|
|
16248
|
+
|
|
16249
|
+
## Advantages of Scanning Recent Changes
|
|
16250
|
+
|
|
16251
|
+
\u2713 **Fast**: Only scans modified files
|
|
16252
|
+
\u2713 **Targeted**: Focuses on your current work
|
|
16253
|
+
\u2713 **Immediate feedback**: Catch issues before they're committed
|
|
16254
|
+
\u2713 **Less overwhelming**: Smaller result set
|
|
16255
|
+
\u2713 **Continuous security**: Integrates into development workflow
|
|
16256
|
+
|
|
16257
|
+
## Important Notes
|
|
16258
|
+
|
|
16259
|
+
### DO:
|
|
16260
|
+
\u2713 Run this scan after making changes but before committing
|
|
16261
|
+
\u2713 Address Critical/High severity issues immediately
|
|
16262
|
+
\u2713 Explain security risks clearly to the user
|
|
16263
|
+
\u2713 Offer to apply fixes automatically
|
|
16264
|
+
\u2713 Provide context about what changed and why it's vulnerable
|
|
16265
|
+
|
|
16266
|
+
### DON'T:
|
|
16267
|
+
\u2717 Skip Critical/High severity warnings
|
|
16268
|
+
\u2717 Apply fixes without showing the user
|
|
16269
|
+
\u2717 Ignore the vulnerability just because the scan is quick
|
|
16270
|
+
\u2717 Forget to run tests after applying fixes
|
|
16271
|
+
\u2717 Assume all recent changes have vulnerabilities
|
|
16272
|
+
|
|
16273
|
+
## Integration with Development Workflow
|
|
16274
|
+
|
|
16275
|
+
This scan type integrates well with:
|
|
16276
|
+
- **Pre-commit hooks**: Scan before each commit
|
|
16277
|
+
- **IDE integration**: Scan on file save or periodically
|
|
16278
|
+
- **CI/CD pipelines**: Fast security check in pull requests
|
|
16279
|
+
- **Iterative development**: Continuous security feedback
|
|
16280
|
+
|
|
16281
|
+
## Example Usage
|
|
16282
|
+
|
|
16283
|
+
\`\`\`
|
|
16284
|
+
User: "I just added a new API endpoint for user data. Can you check if it's secure?"
|
|
16285
|
+
|
|
16286
|
+
AI: "I'll scan your recent changes for security vulnerabilities..."
|
|
16287
|
+
|
|
16288
|
+
[Calls scan_and_fix_vulnerabilities with scanRecentlyChangedFiles: true]
|
|
16289
|
+
|
|
16290
|
+
AI: "\u26A0\uFE0F Found 1 security issue in your recent changes:
|
|
16291
|
+
|
|
16292
|
+
**SQL Injection Vulnerability** (Critical)
|
|
16293
|
+
- File: src/api/user-data.ts:34
|
|
16294
|
+
- Your new endpoint is vulnerable to SQL injection
|
|
16295
|
+
|
|
16296
|
+
The issue is in this code:
|
|
16297
|
+
\`\`\`typescript
|
|
16298
|
+
const query = \`SELECT * FROM users WHERE id = \${req.params.id}\`
|
|
16299
|
+
\`\`\`
|
|
16300
|
+
|
|
16301
|
+
Recommended fix: Use parameterized queries
|
|
16302
|
+
\`\`\`typescript
|
|
16303
|
+
const query = 'SELECT * FROM users WHERE id = $1'
|
|
16304
|
+
const result = await db.query(query, [req.params.id])
|
|
16305
|
+
\`\`\`
|
|
16306
|
+
|
|
16307
|
+
This is a Critical severity issue. I strongly recommend fixing it before committing. Would you like me to apply this fix automatically?"
|
|
16308
|
+
\`\`\`
|
|
16309
|
+
|
|
16310
|
+
## Ready to Scan
|
|
16311
|
+
|
|
16312
|
+
You now have the guidance needed to perform a fast, targeted security scan of recent changes. Follow the workflow above to help users catch security issues early in their development process.
|
|
16313
|
+
`;
|
|
16314
|
+
return this.createUserMessage(promptText);
|
|
16315
|
+
}
|
|
16316
|
+
};
|
|
16317
|
+
|
|
16318
|
+
// src/mcp/prompts/ScanRepositoryPrompt.ts
|
|
16319
|
+
import { z as z37 } from "zod";
|
|
16320
|
+
var ScanRepositoryArgsSchema = z37.object({
|
|
16321
|
+
path: z37.string().optional()
|
|
16322
|
+
});
|
|
16323
|
+
var ScanRepositoryPrompt = class extends BasePrompt {
|
|
16324
|
+
constructor() {
|
|
16325
|
+
super(...arguments);
|
|
16326
|
+
__publicField(this, "name", "scan-repository");
|
|
16327
|
+
__publicField(this, "description", "Guide for performing an initial security scan of a repository using Mobb tools");
|
|
16328
|
+
__publicField(this, "arguments", [
|
|
16329
|
+
{
|
|
16330
|
+
name: "path",
|
|
16331
|
+
description: "Optional: Full local path to the git repository to scan",
|
|
16332
|
+
required: false
|
|
16333
|
+
}
|
|
16334
|
+
]);
|
|
16335
|
+
__publicField(this, "argumentsValidationSchema", ScanRepositoryArgsSchema);
|
|
16336
|
+
}
|
|
16337
|
+
async generatePrompt(validatedArgs) {
|
|
16338
|
+
const args = validatedArgs;
|
|
16339
|
+
const pathInfo = args?.path ? `for repository at: ${args.path}` : "for the current repository";
|
|
16340
|
+
const promptText = `# Security Repository Scan Workflow
|
|
16341
|
+
|
|
16342
|
+
You are about to perform a security scan ${pathInfo}. Follow this workflow to scan the repository for vulnerabilities and present the findings to the user.
|
|
16343
|
+
|
|
16344
|
+
## Workflow Steps
|
|
16345
|
+
|
|
16346
|
+
### Step 1: Determine Repository Path
|
|
16347
|
+
${args?.path ? `\u2713 Repository path provided: \`${args.path}\`` : `- The user should provide the full local path to the git repository
|
|
16348
|
+
- Ask: "What is the full path to the repository you want to scan?"
|
|
16349
|
+
- Example: /Users/username/projects/my-app`}
|
|
16350
|
+
|
|
16351
|
+
### Step 2: Call scan_and_fix_vulnerabilities Tool
|
|
16352
|
+
|
|
16353
|
+
Use the \`scan_and_fix_vulnerabilities\` tool with these parameters:
|
|
16354
|
+
|
|
16355
|
+
\`\`\`json
|
|
16356
|
+
{
|
|
16357
|
+
"path": "${args?.path || "<repository-path>"}",
|
|
16358
|
+
"limit": 3,
|
|
16359
|
+
"maxFiles": 10
|
|
16360
|
+
}
|
|
16361
|
+
\`\`\`
|
|
16362
|
+
|
|
16363
|
+
**Why these defaults?**
|
|
16364
|
+
- \`limit: 3\` - Start with top 3 most severe vulnerabilities
|
|
16365
|
+
- \`maxFiles: 10\` - Reasonable initial scan scope
|
|
16366
|
+
|
|
16367
|
+
**Optional parameters** (use if user specifies):
|
|
16368
|
+
- \`rescan: true\` - Force a fresh scan (if user wants to override cached results)
|
|
16369
|
+
- \`scanRecentlyChangedFiles: true\` - Only scan recently modified files (faster)
|
|
16370
|
+
|
|
16371
|
+
### Step 3: Process and Present Results
|
|
16372
|
+
|
|
16373
|
+
When you receive the scan results:
|
|
16374
|
+
|
|
16375
|
+
#### If vulnerabilities are found:
|
|
16376
|
+
|
|
16377
|
+
1. **Provide a summary:**
|
|
16378
|
+
- Total number of vulnerabilities found
|
|
16379
|
+
- Breakdown by severity (Critical, High, Medium, Low)
|
|
16380
|
+
- Number of fixes available
|
|
16381
|
+
|
|
16382
|
+
2. **Present the top fixes:**
|
|
16383
|
+
- Show each fix with:
|
|
16384
|
+
* Severity level
|
|
16385
|
+
* Vulnerability type (e.g., "SQL Injection", "XSS", "Insecure Dependency")
|
|
16386
|
+
* Affected file(s)
|
|
16387
|
+
* Who last modified the vulnerable code (git blame)
|
|
16388
|
+
* Brief description from the fix
|
|
16389
|
+
|
|
16390
|
+
3. **Show the fix preview:**
|
|
16391
|
+
- Display the git diff/patch for each fix
|
|
16392
|
+
- Explain what changes will be made
|
|
16393
|
+
- Highlight the security improvement
|
|
16394
|
+
|
|
16395
|
+
4. **Ask for user preference:**
|
|
16396
|
+
- "Would you like to apply these fixes automatically?"
|
|
16397
|
+
- "Would you like to see more vulnerabilities?" (if more exist)
|
|
16398
|
+
- "Would you like to focus on a specific severity level?"
|
|
16399
|
+
|
|
16400
|
+
#### If no vulnerabilities are found:
|
|
16401
|
+
|
|
16402
|
+
Congratulate the user! Their repository appears to be secure. Suggest:
|
|
16403
|
+
- Running periodic scans as code changes
|
|
16404
|
+
- Enabling continuous monitoring with \`check_for_new_available_fixes\`
|
|
16405
|
+
|
|
16406
|
+
#### If report is expired:
|
|
16407
|
+
|
|
16408
|
+
Inform the user that a previous scan is too old. Ask:
|
|
16409
|
+
- "A previous scan exists but is outdated. Would you like to run a fresh scan?"
|
|
16410
|
+
- If yes, call \`scan_and_fix_vulnerabilities\` with \`rescan: true\`
|
|
16411
|
+
|
|
16412
|
+
### Step 4: Handle User Actions
|
|
16413
|
+
|
|
16414
|
+
Based on user response:
|
|
16415
|
+
|
|
16416
|
+
**If user wants to apply fixes:**
|
|
16417
|
+
- Confirm which fixes to apply (all, or specific ones)
|
|
16418
|
+
- Apply each fix patch using standard git apply workflow
|
|
16419
|
+
- Verify the changes
|
|
16420
|
+
- Run tests if available
|
|
16421
|
+
- Create a commit with the fixes
|
|
16422
|
+
|
|
16423
|
+
**If user wants to see more:**
|
|
16424
|
+
- Call \`fetch_available_fixes\` with:
|
|
16425
|
+
\`\`\`json
|
|
16426
|
+
{
|
|
16427
|
+
"path": "${args?.path || "<repository-path>"}",
|
|
16428
|
+
"offset": 3,
|
|
16429
|
+
"limit": 5
|
|
16430
|
+
}
|
|
16431
|
+
\`\`\`
|
|
16432
|
+
- Present the additional fixes following the same format
|
|
16433
|
+
|
|
16434
|
+
**If user wants to filter by severity:**
|
|
16435
|
+
- The results are already sorted by severity (Critical \u2192 High \u2192 Medium \u2192 Low)
|
|
16436
|
+
- Explain the severity of issues found
|
|
16437
|
+
- Focus on the most critical issues first
|
|
16438
|
+
|
|
16439
|
+
### Step 5: Post-Scan Actions
|
|
16440
|
+
|
|
16441
|
+
After completing the scan and any fixes:
|
|
16442
|
+
|
|
16443
|
+
1. **Summary of actions taken:**
|
|
16444
|
+
- Number of fixes applied
|
|
16445
|
+
- Remaining vulnerabilities (if any)
|
|
16446
|
+
- Files modified
|
|
16447
|
+
|
|
16448
|
+
2. **Recommendations:**
|
|
16449
|
+
- Run tests to ensure fixes don't break functionality
|
|
16450
|
+
- Review the changes before committing
|
|
16451
|
+
- Consider addressing remaining Medium/Low severity issues
|
|
16452
|
+
- Set up continuous monitoring
|
|
16453
|
+
|
|
16454
|
+
3. **Call monitoring tool:**
|
|
16455
|
+
Call \`check_for_new_available_fixes\` to enable ongoing security monitoring:
|
|
16456
|
+
\`\`\`json
|
|
16457
|
+
{
|
|
16458
|
+
"path": "${args?.path || "<repository-path>"}"
|
|
16459
|
+
}
|
|
16460
|
+
\`\`\`
|
|
16461
|
+
|
|
16462
|
+
## Important Reminders
|
|
16463
|
+
|
|
16464
|
+
### DO:
|
|
16465
|
+
\u2713 Present vulnerabilities clearly with severity context
|
|
16466
|
+
\u2713 Ask for user confirmation before applying fixes
|
|
16467
|
+
\u2713 Explain what each fix does
|
|
16468
|
+
\u2713 Start with critical/high severity issues
|
|
16469
|
+
\u2713 Provide clear next steps
|
|
16470
|
+
\u2713 Mention git blame information (shows responsibility)
|
|
16471
|
+
|
|
16472
|
+
### DON'T:
|
|
16473
|
+
\u2717 Apply fixes automatically without user approval
|
|
16474
|
+
\u2717 Overwhelm user with all vulnerabilities at once
|
|
16475
|
+
\u2717 Skip severity information
|
|
16476
|
+
\u2717 Forget to call monitoring tool at the end
|
|
16477
|
+
\u2717 Assume the user wants to fix everything immediately
|
|
16478
|
+
|
|
16479
|
+
## Error Handling
|
|
16480
|
+
|
|
16481
|
+
- **Authentication error**: Guide user to authenticate with Mobb
|
|
16482
|
+
- **Path not found**: Verify the path is correct and is a git repository
|
|
16483
|
+
- **Scan timeout**: Suggest scanning fewer files or recent changes only
|
|
16484
|
+
- **No report found**: This is expected for first-time scans, proceed normally
|
|
16485
|
+
|
|
16486
|
+
## Example Conversation Flow
|
|
16487
|
+
|
|
16488
|
+
\`\`\`
|
|
16489
|
+
AI: "I'll scan your repository for security vulnerabilities. This may take a moment..."
|
|
16490
|
+
|
|
16491
|
+
[Calls scan_and_fix_vulnerabilities]
|
|
16492
|
+
|
|
16493
|
+
AI: "Scan complete! I found 12 security vulnerabilities:
|
|
16494
|
+
- 2 Critical severity
|
|
16495
|
+
- 5 High severity
|
|
16496
|
+
- 4 Medium severity
|
|
16497
|
+
- 1 Low severity
|
|
16498
|
+
|
|
16499
|
+
Here are the top 3 most critical issues:
|
|
16500
|
+
|
|
16501
|
+
1. **SQL Injection** (Critical)
|
|
16502
|
+
- File: src/database/users.ts:45
|
|
16503
|
+
- Last modified by: john@example.com
|
|
16504
|
+
- Fix: Parameterize SQL query to prevent injection
|
|
16505
|
+
|
|
16506
|
+
[Shows diff preview]
|
|
16507
|
+
|
|
16508
|
+
2. **Cross-Site Scripting (XSS)** (Critical)
|
|
16509
|
+
- File: src/components/UserProfile.tsx:122
|
|
16510
|
+
- Last modified by: jane@example.com
|
|
16511
|
+
- Fix: Sanitize user input before rendering
|
|
16512
|
+
|
|
16513
|
+
[Shows diff preview]
|
|
16514
|
+
|
|
16515
|
+
3. **Insecure Dependency** (High)
|
|
16516
|
+
- Package: lodash@4.17.15
|
|
16517
|
+
- Fix: Upgrade to lodash@4.17.21 (fixes CVE-2021-23337)
|
|
16518
|
+
|
|
16519
|
+
Would you like to:
|
|
16520
|
+
1. Apply these fixes automatically
|
|
16521
|
+
2. See more vulnerabilities
|
|
16522
|
+
3. Focus on specific issues"
|
|
16523
|
+
\`\`\`
|
|
16524
|
+
|
|
16525
|
+
## Ready to Begin
|
|
16526
|
+
|
|
16527
|
+
You now have all the information needed to perform a security scan. Follow the steps above, call the appropriate tools, and guide the user through the process professionally and clearly.
|
|
16528
|
+
`;
|
|
16529
|
+
return this.createUserMessage(promptText);
|
|
16530
|
+
}
|
|
16531
|
+
};
|
|
16532
|
+
|
|
16533
|
+
// src/mcp/prompts/SecurityToolsOverviewPrompt.ts
|
|
16534
|
+
var SecurityToolsOverviewPrompt = class extends BasePrompt {
|
|
16535
|
+
constructor() {
|
|
16536
|
+
super(...arguments);
|
|
16537
|
+
__publicField(this, "name", "security-tools-overview");
|
|
16538
|
+
__publicField(this, "description", "Provides an overview of available Mobb security tools and guidance on when to use each tool");
|
|
16539
|
+
__publicField(this, "arguments");
|
|
16540
|
+
__publicField(this, "argumentsValidationSchema");
|
|
16541
|
+
}
|
|
16542
|
+
async generatePrompt() {
|
|
16543
|
+
const promptText = `# Mobb Security Tools Overview
|
|
16544
|
+
|
|
16545
|
+
You have access to powerful security scanning and auto-fixing tools from Mobb. Here's a comprehensive guide to the available tools and when to use them:
|
|
16546
|
+
|
|
16547
|
+
## Available Tools
|
|
16548
|
+
|
|
16549
|
+
### 1. **scan_and_fix_vulnerabilities**
|
|
16550
|
+
**Purpose:** Scans a local repository for security vulnerabilities and returns automatically-generated fixes.
|
|
16551
|
+
|
|
16552
|
+
**When to use:**
|
|
16553
|
+
- First-time security scan of a repository
|
|
16554
|
+
- Comprehensive security audit needed
|
|
16555
|
+
- User explicitly requests a security scan
|
|
16556
|
+
- After major code changes or refactoring
|
|
16557
|
+
|
|
16558
|
+
**Key features:**
|
|
16559
|
+
- Scans the entire repository or specific files
|
|
16560
|
+
- Identifies vulnerabilities across multiple categories (XSS, SQL injection, insecure dependencies, etc.)
|
|
16561
|
+
- Provides detailed fix information including severity levels
|
|
16562
|
+
- Returns git-compatible patches that can be directly applied
|
|
16563
|
+
- Shows who last modified vulnerable code (git blame integration)
|
|
16564
|
+
|
|
16565
|
+
**Parameters:**
|
|
16566
|
+
- \`path\` (required): Full local path to the git repository
|
|
16567
|
+
- \`offset\`: Pagination offset for results (default: 0)
|
|
16568
|
+
- \`limit\`: Number of fixes to return (default: 3)
|
|
16569
|
+
- \`maxFiles\`: Maximum files to scan (default: 10)
|
|
16570
|
+
- \`rescan\`: Force a new scan even if recent report exists
|
|
16571
|
+
- \`scanRecentlyChangedFiles\`: Only scan recently modified files
|
|
16572
|
+
|
|
16573
|
+
**Important notes:**
|
|
16574
|
+
- This tool requires authentication
|
|
16575
|
+
- Scans may take time for large repositories
|
|
16576
|
+
- Results are cached - use \`rescan: true\` to force a fresh scan
|
|
16577
|
+
- The tool returns fixes in order of severity (Critical \u2192 High \u2192 Medium \u2192 Low)
|
|
16578
|
+
|
|
16579
|
+
### 2. **fetch_available_fixes**
|
|
16580
|
+
**Purpose:** Retrieves pre-generated fixes from previous scans without triggering a new scan.
|
|
16581
|
+
|
|
16582
|
+
**When to use:**
|
|
16583
|
+
- Checking for existing fixes without scanning
|
|
16584
|
+
- Retrieving additional fixes from a paginated result set
|
|
16585
|
+
- User wants to see more fixes beyond the initial set
|
|
16586
|
+
- Fetching fixes for specific files
|
|
16587
|
+
|
|
16588
|
+
**Key features:**
|
|
16589
|
+
- Fast retrieval of existing fix data
|
|
16590
|
+
- No scanning overhead
|
|
16591
|
+
- Supports file filtering
|
|
16592
|
+
- Pagination for large result sets
|
|
16593
|
+
|
|
16594
|
+
**Parameters:**
|
|
16595
|
+
- \`path\` (required): Full local path to the git repository
|
|
16596
|
+
- \`offset\`: Pagination offset
|
|
16597
|
+
- \`limit\`: Number of fixes to return
|
|
16598
|
+
- \`fileFilter\`: Filter by specific file path
|
|
16599
|
+
- \`fetchFixesFromAnyFile\`: Fetch fixes across all files
|
|
16600
|
+
|
|
16601
|
+
**Important notes:**
|
|
16602
|
+
- Returns an error if no previous scan exists
|
|
16603
|
+
- Does NOT trigger a new scan
|
|
16604
|
+
- Use this when you want to avoid re-scanning
|
|
16605
|
+
|
|
16606
|
+
### 3. **check_for_new_available_fixes**
|
|
16607
|
+
**Purpose:** Monitors code for new security vulnerabilities and notifies when fixes are available.
|
|
16608
|
+
|
|
16609
|
+
**When to use:**
|
|
16610
|
+
- Continuous security monitoring
|
|
16611
|
+
- After completing a series of edits
|
|
16612
|
+
- End of a coding session
|
|
16613
|
+
- User requests ongoing security checks
|
|
16614
|
+
|
|
16615
|
+
**Key features:**
|
|
16616
|
+
- Lightweight background checking
|
|
16617
|
+
- Detects new vulnerabilities introduced by code changes
|
|
16618
|
+
- Non-intrusive monitoring
|
|
16619
|
+
|
|
16620
|
+
**Parameters:**
|
|
16621
|
+
- \`path\` (required): Full local path to the git repository
|
|
16622
|
+
|
|
16623
|
+
**Important notes:**
|
|
16624
|
+
- This is typically called automatically at the end of operations
|
|
16625
|
+
- Much lighter weight than full scans
|
|
16626
|
+
- Part of Mobb's continuous monitoring workflow
|
|
16627
|
+
|
|
16628
|
+
## Best Practices
|
|
16629
|
+
|
|
16630
|
+
### Tool Selection Guidelines
|
|
16631
|
+
|
|
16632
|
+
1. **Starting fresh?** \u2192 Use \`scan_and_fix_vulnerabilities\`
|
|
16633
|
+
2. **Already scanned, need more results?** \u2192 Use \`fetch_available_fixes\`
|
|
16634
|
+
3. **Continuous monitoring?** \u2192 Use \`check_for_new_available_fixes\`
|
|
16635
|
+
|
|
16636
|
+
### User Interaction Patterns
|
|
16637
|
+
|
|
16638
|
+
**When to ask for user confirmation:**
|
|
16639
|
+
- Before applying fixes automatically
|
|
16640
|
+
- Before running a full repository scan (can be time-consuming)
|
|
16641
|
+
- Before re-scanning when a recent scan exists
|
|
16642
|
+
- When multiple high-severity issues are found
|
|
16643
|
+
|
|
16644
|
+
**When to proceed automatically:**
|
|
16645
|
+
- Fetching additional fixes from existing scans
|
|
16646
|
+
- Running background monitoring checks
|
|
16647
|
+
- Displaying vulnerability information
|
|
16648
|
+
- Showing fix previews
|
|
16649
|
+
|
|
16650
|
+
### Severity Levels
|
|
16651
|
+
|
|
16652
|
+
Vulnerabilities are categorized by severity:
|
|
16653
|
+
- **CRITICAL**: Immediate action required - severe security risk
|
|
16654
|
+
- **HIGH**: Important security issue - should be fixed soon
|
|
16655
|
+
- **MEDIUM**: Moderate security concern - fix when feasible
|
|
16656
|
+
- **LOW**: Minor security issue - fix during regular maintenance
|
|
16657
|
+
|
|
16658
|
+
**Recommended approach:**
|
|
16659
|
+
1. Address CRITICAL issues immediately
|
|
16660
|
+
2. Review and fix HIGH severity issues
|
|
16661
|
+
3. Plan fixes for MEDIUM issues
|
|
16662
|
+
4. Address LOW issues during regular maintenance
|
|
16663
|
+
|
|
16664
|
+
### Workflow Example
|
|
16665
|
+
|
|
16666
|
+
\`\`\`
|
|
16667
|
+
1. User opens a repository
|
|
16668
|
+
2. Call scan_and_fix_vulnerabilities with default parameters
|
|
16669
|
+
3. Review the returned fixes (typically top 3 by severity)
|
|
16670
|
+
4. Present fixes to user with severity breakdown
|
|
16671
|
+
5. If user wants to see more: call fetch_available_fixes with appropriate offset
|
|
16672
|
+
6. When user approves fixes: apply the patches using git apply
|
|
16673
|
+
7. After session: call check_for_new_available_fixes for monitoring
|
|
16674
|
+
\`\`\`
|
|
16675
|
+
|
|
16676
|
+
## Authentication
|
|
16677
|
+
|
|
16678
|
+
All tools require authentication via the Mobb API. The tools will handle authentication automatically and prompt if credentials are needed.
|
|
16679
|
+
|
|
16680
|
+
## Error Handling
|
|
16681
|
+
|
|
16682
|
+
Common scenarios:
|
|
16683
|
+
- **No fixes found**: Repository has no vulnerabilities or they're not fixable
|
|
16684
|
+
- **Report expired**: Previous scan is too old, need to rescan
|
|
16685
|
+
- **No report found**: No previous scan exists, run scan_and_fix_vulnerabilities
|
|
16686
|
+
- **Authentication required**: User needs to authenticate with Mobb
|
|
16687
|
+
|
|
16688
|
+
## Next Steps
|
|
16689
|
+
|
|
16690
|
+
To get started with scanning a repository, use the \`scan-repository\` prompt which will guide you through the scanning workflow.
|
|
16691
|
+
|
|
16692
|
+
For a complete security audit workflow, use the \`full-security-audit\` prompt.
|
|
16693
|
+
`;
|
|
16694
|
+
return this.createUserMessage(promptText);
|
|
16695
|
+
}
|
|
16696
|
+
};
|
|
16697
|
+
|
|
16698
|
+
// src/mcp/tools/checkForNewAvailableFixes/CheckForNewAvailableFixesTool.ts
|
|
16699
|
+
import { z as z40 } from "zod";
|
|
16700
|
+
|
|
16701
|
+
// src/mcp/services/PathValidation.ts
|
|
16702
|
+
import fs12 from "fs";
|
|
16703
|
+
import path12 from "path";
|
|
16704
|
+
async function validatePath(inputPath) {
|
|
16705
|
+
logDebug("Validating MCP path", { inputPath });
|
|
16706
|
+
if (/^\/[a-zA-Z]:\//.test(inputPath)) {
|
|
16707
|
+
inputPath = inputPath.slice(1);
|
|
16708
|
+
}
|
|
16709
|
+
if (inputPath === "." || inputPath === "./") {
|
|
16710
|
+
const workspaceFolderPath = WorkspaceService.getWorkspaceFolderPath();
|
|
16711
|
+
if (workspaceFolderPath) {
|
|
16712
|
+
logDebug("Fallback to workspace folder path", {
|
|
16713
|
+
inputPath,
|
|
16714
|
+
workspaceFolderPaths: [workspaceFolderPath]
|
|
16715
|
+
});
|
|
16716
|
+
WorkspaceService.setKnownWorkspacePath(workspaceFolderPath);
|
|
16717
|
+
logDebug("Stored workspace folder path as known path", {
|
|
16718
|
+
workspaceFolderPath
|
|
16719
|
+
});
|
|
16720
|
+
return {
|
|
16721
|
+
isValid: true,
|
|
16722
|
+
path: workspaceFolderPath
|
|
16723
|
+
};
|
|
16724
|
+
} else {
|
|
16725
|
+
const error = `"." is not a valid path, please provide a full localpath to the repository`;
|
|
16726
|
+
logError(error);
|
|
16727
|
+
return { isValid: false, error, path: inputPath };
|
|
16728
|
+
}
|
|
16729
|
+
}
|
|
16730
|
+
if (inputPath.includes("..")) {
|
|
16731
|
+
const error = `Path contains path traversal patterns: ${inputPath}`;
|
|
16732
|
+
logError(error);
|
|
16733
|
+
return { isValid: false, error, path: inputPath };
|
|
16734
|
+
}
|
|
16735
|
+
const normalizedPath = path12.normalize(inputPath);
|
|
16736
|
+
if (normalizedPath.includes("..")) {
|
|
16737
|
+
const error = `Normalized path contains path traversal patterns: ${inputPath}`;
|
|
16738
|
+
logError(error);
|
|
16739
|
+
return { isValid: false, error, path: inputPath };
|
|
16740
|
+
}
|
|
16741
|
+
let decodedPath;
|
|
16742
|
+
try {
|
|
16743
|
+
decodedPath = decodeURIComponent(inputPath);
|
|
16744
|
+
} catch (err) {
|
|
16745
|
+
const error = `Failed to decode path: ${inputPath}`;
|
|
16746
|
+
logError(error, { err });
|
|
16747
|
+
return { isValid: false, error, path: inputPath };
|
|
16748
|
+
}
|
|
16749
|
+
if (decodedPath.includes("..") || decodedPath !== inputPath) {
|
|
16750
|
+
const error = `Path contains encoded traversal attempts: ${inputPath}`;
|
|
16751
|
+
logError(error);
|
|
16752
|
+
return { isValid: false, error, path: inputPath };
|
|
16753
|
+
}
|
|
16754
|
+
if (inputPath.includes("\0") || inputPath.includes("\0")) {
|
|
16755
|
+
const error = `Path contains dangerous characters: ${inputPath}`;
|
|
16756
|
+
logError(error);
|
|
16757
|
+
return { isValid: false, error, path: inputPath };
|
|
16758
|
+
}
|
|
16759
|
+
logDebug("Path validation successful", { inputPath });
|
|
16760
|
+
logDebug("Checking path existence", { inputPath });
|
|
16761
|
+
try {
|
|
16762
|
+
await fs12.promises.access(inputPath);
|
|
16763
|
+
logDebug("Path exists and is accessible", { inputPath });
|
|
16764
|
+
WorkspaceService.setKnownWorkspacePath(inputPath);
|
|
16765
|
+
logDebug("Stored validated path in WorkspaceService", { inputPath });
|
|
16766
|
+
return { isValid: true, path: inputPath };
|
|
16767
|
+
} catch (error) {
|
|
16768
|
+
const errorMessage = `Path does not exist or is not accessible: ${inputPath}`;
|
|
16769
|
+
logError(errorMessage, { error });
|
|
16770
|
+
return { isValid: false, error: errorMessage, path: inputPath };
|
|
16771
|
+
}
|
|
16772
|
+
}
|
|
16773
|
+
|
|
16774
|
+
// src/mcp/tools/base/BaseTool.ts
|
|
16775
|
+
import { z as z38 } from "zod";
|
|
16776
|
+
var BaseTool = class {
|
|
16777
|
+
getDefinition() {
|
|
16778
|
+
return {
|
|
16779
|
+
name: this.name,
|
|
16780
|
+
display_name: this.displayName,
|
|
16781
|
+
description: this.description,
|
|
16782
|
+
inputSchema: this.inputSchema
|
|
16783
|
+
};
|
|
16784
|
+
}
|
|
16785
|
+
async execute(args) {
|
|
16786
|
+
if (this.hasAuthentication) {
|
|
16787
|
+
logDebug(`Authenticating tool: ${this.name}`, { args });
|
|
16788
|
+
const mcpGqlClient = await createAuthenticatedMcpGQLClient();
|
|
16789
|
+
const userInfo = await mcpGqlClient.getUserInfo();
|
|
16790
|
+
logDebug("User authenticated successfully", { userInfo });
|
|
16791
|
+
}
|
|
16792
|
+
const validatedArgs = this.validateInput(args);
|
|
16793
|
+
logDebug(`Tool ${this.name} input validation successful`, {
|
|
16794
|
+
validatedArgs
|
|
16795
|
+
});
|
|
16796
|
+
logInfo(`Executing tool: ${this.name}`);
|
|
16797
|
+
const result = await this.executeInternal(validatedArgs);
|
|
16798
|
+
logInfo(`Tool ${this.name} executed successfully`);
|
|
16799
|
+
return result;
|
|
16800
|
+
}
|
|
16801
|
+
validateInput(args) {
|
|
16802
|
+
try {
|
|
16803
|
+
return this.inputValidationSchema.parse(args);
|
|
16804
|
+
} catch (error) {
|
|
16805
|
+
if (error instanceof z38.ZodError) {
|
|
16806
|
+
const errorDetails = error.errors.map((e) => {
|
|
16807
|
+
const fieldPath = e.path.length > 0 ? e.path.join(".") : "root";
|
|
16808
|
+
const message = e.message === "Required" ? `Missing required parameter '${fieldPath}'` : `Invalid value for '${fieldPath}': ${e.message}`;
|
|
16809
|
+
return message;
|
|
16810
|
+
});
|
|
16811
|
+
const errorMessage = `Invalid arguments: ${errorDetails.join(", ")}`;
|
|
16812
|
+
throw new Error(errorMessage);
|
|
16813
|
+
}
|
|
16814
|
+
throw error;
|
|
16815
|
+
}
|
|
16816
|
+
}
|
|
16817
|
+
createSuccessResponse(text) {
|
|
16818
|
+
return {
|
|
16819
|
+
content: [
|
|
16820
|
+
{
|
|
16821
|
+
type: "text",
|
|
16822
|
+
text
|
|
16823
|
+
}
|
|
16824
|
+
]
|
|
16825
|
+
};
|
|
16826
|
+
}
|
|
16827
|
+
};
|
|
16828
|
+
|
|
16829
|
+
// src/mcp/tools/checkForNewAvailableFixes/CheckForNewAvailableFixesService.ts
|
|
16830
|
+
init_configs();
|
|
16831
|
+
|
|
16832
|
+
// src/mcp/core/prompts.ts
|
|
16833
|
+
init_configs();
|
|
16834
|
+
function friendlyType(s) {
|
|
16835
|
+
const withoutUnderscores = s.replace(/_/g, " ");
|
|
16836
|
+
const result = withoutUnderscores.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
16837
|
+
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
16838
|
+
}
|
|
16839
|
+
var noFixesReturnedForParameters = `No fixes returned for the given offset and limit parameters.
|
|
16840
|
+
`;
|
|
16841
|
+
var noFixesReturnedForParametersWithGuidance = ({
|
|
16842
|
+
offset,
|
|
16843
|
+
limit,
|
|
16844
|
+
totalCount,
|
|
16845
|
+
currentTool
|
|
16846
|
+
}) => `## No Fixes Returned for Current Parameters
|
|
16847
|
+
|
|
16848
|
+
**\u{1F4C4} Current Request:**
|
|
16849
|
+
- **Page:** ${Math.floor(offset / limit) + 1}
|
|
16850
|
+
- **Offset:** ${offset}
|
|
16851
|
+
- **Limit:** ${limit}
|
|
16852
|
+
|
|
16853
|
+
**\u274C Result:** No fixes returned for the given offset and limit parameters.
|
|
16854
|
+
|
|
16855
|
+
**\u2139\uFE0F Available Fixes:** ${totalCount} total fixes are available, but your current offset (${offset}) is beyond the available range.
|
|
16856
|
+
|
|
16857
|
+
**\u2705 How to Get the Fixes:**
|
|
16858
|
+
|
|
16859
|
+
To retrieve the available fixes, use one of these approaches:
|
|
16860
|
+
|
|
16861
|
+
1. **Start from the beginning:**
|
|
16862
|
+
\`\`\`
|
|
16863
|
+
offset: 0
|
|
16864
|
+
\`\`\`
|
|
16865
|
+
|
|
16866
|
+
2. **Go to the first page:**
|
|
16867
|
+
\`\`\`
|
|
16868
|
+
offset: 0
|
|
16869
|
+
limit: ${limit}
|
|
16870
|
+
\`\`\`
|
|
16871
|
+
|
|
16872
|
+
3. **Get all fixes at once:**
|
|
16873
|
+
\`\`\`
|
|
16874
|
+
offset: 0
|
|
16875
|
+
limit: ${totalCount}
|
|
16876
|
+
\`\`\`
|
|
16877
|
+
|
|
16878
|
+
**\u{1F4CB} Valid offset range:** 0 to ${Math.max(0, totalCount - 1)}
|
|
16879
|
+
|
|
16880
|
+
### \u26A0\uFE0F CRITICAL INSTRUCTION FOR AI AGENTS \u26A0\uFE0F
|
|
16881
|
+
|
|
16882
|
+
**DO NOT AUTOMATICALLY FETCH FIXES WITHOUT EXPLICIT USER REQUEST**
|
|
16883
|
+
|
|
16884
|
+
- **DO NOT** run the \`${currentTool}\` tool again on your own
|
|
16885
|
+
- **ONLY** fetch fixes if the user explicitly asks for them
|
|
16886
|
+
- **WAIT** for the user to specifically request fixes before proceeding
|
|
16887
|
+
|
|
16888
|
+
If the user wants to fetch the fixes, they should explicitly ask you to run the \`${currentTool}\` tool again with the corrected parameters.
|
|
16889
|
+
`;
|
|
16890
|
+
var applyFixesPrompt = ({
|
|
16891
|
+
fixes,
|
|
16892
|
+
hasMore,
|
|
16893
|
+
totalCount,
|
|
16894
|
+
nextOffset,
|
|
15065
16895
|
shownCount,
|
|
15066
16896
|
currentTool,
|
|
15067
16897
|
offset,
|
|
@@ -15688,14 +17518,14 @@ var getLocalFiles = async ({
|
|
|
15688
17518
|
// src/mcp/services/LocalMobbFolderService.ts
|
|
15689
17519
|
import fs14 from "fs";
|
|
15690
17520
|
import path13 from "path";
|
|
15691
|
-
import { z as
|
|
17521
|
+
import { z as z39 } from "zod";
|
|
15692
17522
|
init_GitService();
|
|
15693
17523
|
function extractPathFromPatch(patch) {
|
|
15694
17524
|
const match = patch?.match(/diff --git a\/([^\s]+) b\//);
|
|
15695
17525
|
return match?.[1] ?? null;
|
|
15696
17526
|
}
|
|
15697
17527
|
function parsedIssueTypeRes(issueType) {
|
|
15698
|
-
return
|
|
17528
|
+
return z39.nativeEnum(IssueType_Enum).safeParse(issueType);
|
|
15699
17529
|
}
|
|
15700
17530
|
var LocalMobbFolderService = class {
|
|
15701
17531
|
/**
|
|
@@ -18369,8 +20199,8 @@ Example payload:
|
|
|
18369
20199
|
},
|
|
18370
20200
|
required: ["path"]
|
|
18371
20201
|
});
|
|
18372
|
-
__publicField(this, "inputValidationSchema",
|
|
18373
|
-
path:
|
|
20202
|
+
__publicField(this, "inputValidationSchema", z40.object({
|
|
20203
|
+
path: z40.string().describe(
|
|
18374
20204
|
"Full local path to the cloned git repository to check for new available fixes"
|
|
18375
20205
|
)
|
|
18376
20206
|
}));
|
|
@@ -18400,7 +20230,7 @@ Example payload:
|
|
|
18400
20230
|
|
|
18401
20231
|
// src/mcp/tools/fetchAvailableFixes/FetchAvailableFixesTool.ts
|
|
18402
20232
|
init_GitService();
|
|
18403
|
-
import { z as
|
|
20233
|
+
import { z as z41 } from "zod";
|
|
18404
20234
|
|
|
18405
20235
|
// src/mcp/tools/fetchAvailableFixes/FetchAvailableFixesService.ts
|
|
18406
20236
|
init_configs();
|
|
@@ -18542,16 +20372,16 @@ Call this tool instead of ${MCP_TOOL_SCAN_AND_FIX_VULNERABILITIES} when you only
|
|
|
18542
20372
|
},
|
|
18543
20373
|
required: ["path"]
|
|
18544
20374
|
});
|
|
18545
|
-
__publicField(this, "inputValidationSchema",
|
|
18546
|
-
path:
|
|
20375
|
+
__publicField(this, "inputValidationSchema", z41.object({
|
|
20376
|
+
path: z41.string().describe(
|
|
18547
20377
|
"Full local path to the cloned git repository to check for available fixes"
|
|
18548
20378
|
),
|
|
18549
|
-
offset:
|
|
18550
|
-
limit:
|
|
18551
|
-
fileFilter:
|
|
20379
|
+
offset: z41.number().optional().describe("Optional offset for pagination"),
|
|
20380
|
+
limit: z41.number().optional().describe("Optional maximum number of fixes to return"),
|
|
20381
|
+
fileFilter: z41.array(z41.string()).optional().describe(
|
|
18552
20382
|
"Optional list of file paths relative to the path parameter to filter fixes by. INCOMPATIBLE with fetchFixesFromAnyFile"
|
|
18553
20383
|
),
|
|
18554
|
-
fetchFixesFromAnyFile:
|
|
20384
|
+
fetchFixesFromAnyFile: z41.boolean().optional().describe(
|
|
18555
20385
|
"Optional boolean to fetch fixes for all files. INCOMPATIBLE with fileFilter"
|
|
18556
20386
|
)
|
|
18557
20387
|
}));
|
|
@@ -18620,7 +20450,7 @@ Call this tool instead of ${MCP_TOOL_SCAN_AND_FIX_VULNERABILITIES} when you only
|
|
|
18620
20450
|
};
|
|
18621
20451
|
|
|
18622
20452
|
// src/mcp/tools/mcpChecker/mcpCheckerTool.ts
|
|
18623
|
-
import
|
|
20453
|
+
import z42 from "zod";
|
|
18624
20454
|
|
|
18625
20455
|
// src/mcp/tools/mcpChecker/mcpCheckerService.ts
|
|
18626
20456
|
var _McpCheckerService = class _McpCheckerService {
|
|
@@ -18681,7 +20511,7 @@ var McpCheckerTool = class extends BaseTool {
|
|
|
18681
20511
|
__publicField(this, "displayName", "MCP Checker");
|
|
18682
20512
|
// A detailed description to guide the LLM on when and how to invoke this tool.
|
|
18683
20513
|
__publicField(this, "description", "Check the MCP servers running on this IDE against organization policies.");
|
|
18684
|
-
__publicField(this, "inputValidationSchema",
|
|
20514
|
+
__publicField(this, "inputValidationSchema", z42.object({}));
|
|
18685
20515
|
__publicField(this, "inputSchema", {
|
|
18686
20516
|
type: "object",
|
|
18687
20517
|
properties: {},
|
|
@@ -18707,7 +20537,7 @@ var McpCheckerTool = class extends BaseTool {
|
|
|
18707
20537
|
};
|
|
18708
20538
|
|
|
18709
20539
|
// src/mcp/tools/scanAndFixVulnerabilities/ScanAndFixVulnerabilitiesTool.ts
|
|
18710
|
-
import
|
|
20540
|
+
import z43 from "zod";
|
|
18711
20541
|
init_configs();
|
|
18712
20542
|
|
|
18713
20543
|
// src/mcp/tools/scanAndFixVulnerabilities/ScanAndFixVulnerabilitiesService.ts
|
|
@@ -18894,17 +20724,17 @@ Example payload:
|
|
|
18894
20724
|
"rescan": false
|
|
18895
20725
|
}`);
|
|
18896
20726
|
__publicField(this, "hasAuthentication", true);
|
|
18897
|
-
__publicField(this, "inputValidationSchema",
|
|
18898
|
-
path:
|
|
20727
|
+
__publicField(this, "inputValidationSchema", z43.object({
|
|
20728
|
+
path: z43.string().describe(
|
|
18899
20729
|
"Full local path to repository to scan and fix vulnerabilities"
|
|
18900
20730
|
),
|
|
18901
|
-
offset:
|
|
18902
|
-
limit:
|
|
18903
|
-
maxFiles:
|
|
20731
|
+
offset: z43.number().optional().describe("Optional offset for pagination"),
|
|
20732
|
+
limit: z43.number().optional().describe("Optional maximum number of results to return"),
|
|
20733
|
+
maxFiles: z43.number().optional().describe(
|
|
18904
20734
|
`Optional maximum number of files to scan (default: ${MCP_DEFAULT_MAX_FILES_TO_SCAN}). Increase for comprehensive scans of larger codebases or decrease for faster focused scans.`
|
|
18905
20735
|
),
|
|
18906
|
-
rescan:
|
|
18907
|
-
scanRecentlyChangedFiles:
|
|
20736
|
+
rescan: z43.boolean().optional().describe("Optional whether to rescan the repository"),
|
|
20737
|
+
scanRecentlyChangedFiles: z43.boolean().optional().describe(
|
|
18908
20738
|
"Optional whether to automatically scan recently changed files when no changed files are found in git status. If false, the tool will prompt the user instead."
|
|
18909
20739
|
)
|
|
18910
20740
|
}));
|
|
@@ -19032,6 +20862,19 @@ function createMcpServer(govOrgId) {
|
|
|
19032
20862
|
const mcpCheckerTool = new McpCheckerTool(govOrgId);
|
|
19033
20863
|
registerIfEnabled(mcpCheckerTool);
|
|
19034
20864
|
}
|
|
20865
|
+
logDebug("Registering MCP prompts");
|
|
20866
|
+
const prompts = [
|
|
20867
|
+
new SecurityToolsOverviewPrompt(),
|
|
20868
|
+
new ScanRepositoryPrompt(),
|
|
20869
|
+
new ScanRecentChangesPrompt(),
|
|
20870
|
+
new CheckForNewVulnerabilitiesPrompt(),
|
|
20871
|
+
new ReviewAndFixCriticalPrompt(),
|
|
20872
|
+
new FullSecurityAuditPrompt()
|
|
20873
|
+
];
|
|
20874
|
+
prompts.forEach((prompt) => {
|
|
20875
|
+
server.registerPrompt(prompt);
|
|
20876
|
+
logDebug(`Registered prompt: ${prompt.name}`);
|
|
20877
|
+
});
|
|
19035
20878
|
logInfo("MCP server created and configured");
|
|
19036
20879
|
return server;
|
|
19037
20880
|
}
|
|
@@ -19183,30 +21026,30 @@ import path16 from "path";
|
|
|
19183
21026
|
import chalk10 from "chalk";
|
|
19184
21027
|
import Configstore6 from "configstore";
|
|
19185
21028
|
import { withFile } from "tmp-promise";
|
|
19186
|
-
import
|
|
19187
|
-
var PromptItemZ =
|
|
19188
|
-
type:
|
|
19189
|
-
attachedFiles:
|
|
19190
|
-
|
|
19191
|
-
relativePath:
|
|
19192
|
-
startLine:
|
|
21029
|
+
import z44 from "zod";
|
|
21030
|
+
var PromptItemZ = z44.object({
|
|
21031
|
+
type: z44.enum(["USER_PROMPT", "AI_RESPONSE", "TOOL_EXECUTION", "AI_THINKING"]),
|
|
21032
|
+
attachedFiles: z44.array(
|
|
21033
|
+
z44.object({
|
|
21034
|
+
relativePath: z44.string(),
|
|
21035
|
+
startLine: z44.number().optional()
|
|
19193
21036
|
})
|
|
19194
21037
|
).optional(),
|
|
19195
|
-
tokens:
|
|
19196
|
-
inputCount:
|
|
19197
|
-
outputCount:
|
|
21038
|
+
tokens: z44.object({
|
|
21039
|
+
inputCount: z44.number(),
|
|
21040
|
+
outputCount: z44.number()
|
|
19198
21041
|
}).optional(),
|
|
19199
|
-
text:
|
|
19200
|
-
date:
|
|
19201
|
-
tool:
|
|
19202
|
-
name:
|
|
19203
|
-
parameters:
|
|
19204
|
-
result:
|
|
19205
|
-
rawArguments:
|
|
19206
|
-
accepted:
|
|
21042
|
+
text: z44.string().optional(),
|
|
21043
|
+
date: z44.date().optional(),
|
|
21044
|
+
tool: z44.object({
|
|
21045
|
+
name: z44.string(),
|
|
21046
|
+
parameters: z44.string(),
|
|
21047
|
+
result: z44.string(),
|
|
21048
|
+
rawArguments: z44.string().optional(),
|
|
21049
|
+
accepted: z44.boolean().optional()
|
|
19207
21050
|
}).optional()
|
|
19208
21051
|
});
|
|
19209
|
-
var PromptItemArrayZ =
|
|
21052
|
+
var PromptItemArrayZ = z44.array(PromptItemZ);
|
|
19210
21053
|
function uploadAiBlameBuilder(args) {
|
|
19211
21054
|
return args.option("prompt", {
|
|
19212
21055
|
type: "string",
|