nexus-agents 2.34.0 → 2.40.0
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/{chunk-A6Q2NRXT.js → chunk-6PLFRWIP.js} +158 -1
- package/dist/chunk-6PLFRWIP.js.map +1 -0
- package/dist/{chunk-YW5QDPGU.js → chunk-DDPRXENZ.js} +3 -3
- package/dist/{chunk-QOULVKG6.js → chunk-LHHVH6FN.js} +2 -2
- package/dist/{chunk-GYAQOHQ4.js → chunk-R652E64E.js} +4 -4
- package/dist/{chunk-GYAQOHQ4.js.map → chunk-R652E64E.js.map} +1 -1
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +670 -121
- package/dist/cli.js.map +1 -1
- package/dist/{consensus-vote-ZGO6RX3V.js → consensus-vote-U465HI3O.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/{setup-command-N6MTXKV3.js → setup-command-7QJR42JE.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-A6Q2NRXT.js.map +0 -1
- /package/dist/{chunk-YW5QDPGU.js.map → chunk-DDPRXENZ.js.map} +0 -0
- /package/dist/{chunk-QOULVKG6.js.map → chunk-LHHVH6FN.js.map} +0 -0
- /package/dist/{consensus-vote-ZGO6RX3V.js.map → consensus-vote-U465HI3O.js.map} +0 -0
- /package/dist/{setup-command-N6MTXKV3.js.map → setup-command-7QJR42JE.js.map} +0 -0
|
@@ -795,6 +795,157 @@ function contextForLogging(ctx) {
|
|
|
795
795
|
};
|
|
796
796
|
}
|
|
797
797
|
|
|
798
|
+
// src/security/access-constraint-deriver/denylist.ts
|
|
799
|
+
var UNBYPASSABLE_PATH_PATTERNS = [
|
|
800
|
+
// Environment files
|
|
801
|
+
".env",
|
|
802
|
+
".env.*",
|
|
803
|
+
"**/.env",
|
|
804
|
+
"**/.env.*",
|
|
805
|
+
// SSH credentials
|
|
806
|
+
"~/.ssh/**",
|
|
807
|
+
"**/ssh/id_*",
|
|
808
|
+
"**/*_rsa",
|
|
809
|
+
"**/*_ed25519",
|
|
810
|
+
"**/*.pem",
|
|
811
|
+
// Cloud credentials
|
|
812
|
+
"~/.aws/**",
|
|
813
|
+
"~/.azure/**",
|
|
814
|
+
"~/.gcp/**",
|
|
815
|
+
"~/.config/gcloud/**",
|
|
816
|
+
"~/.kube/config",
|
|
817
|
+
// Unix secret files
|
|
818
|
+
"/etc/shadow",
|
|
819
|
+
"/etc/sudoers",
|
|
820
|
+
"/etc/sudoers.d/**",
|
|
821
|
+
// Common secret file patterns
|
|
822
|
+
"**/secrets.*",
|
|
823
|
+
"**/credentials.*",
|
|
824
|
+
"**/private_key.*",
|
|
825
|
+
"**/id_rsa*"
|
|
826
|
+
];
|
|
827
|
+
var UNBYPASSABLE_TOOL_NAMES = [
|
|
828
|
+
// Destructive git operations
|
|
829
|
+
"git_push_force",
|
|
830
|
+
"git_reset_hard",
|
|
831
|
+
"git_branch_delete_force",
|
|
832
|
+
"git_clean_force",
|
|
833
|
+
// Destructive filesystem
|
|
834
|
+
"rm_recursive_force",
|
|
835
|
+
"chmod_recursive",
|
|
836
|
+
// Identity / auth mutations
|
|
837
|
+
"ssh_add_key",
|
|
838
|
+
"gpg_add_key",
|
|
839
|
+
"npm_publish_force",
|
|
840
|
+
// Remote destruction
|
|
841
|
+
"github_repo_delete",
|
|
842
|
+
"github_org_transfer",
|
|
843
|
+
"aws_account_close"
|
|
844
|
+
];
|
|
845
|
+
function compileGlobToRegex(pattern) {
|
|
846
|
+
const pat = pattern.toLowerCase();
|
|
847
|
+
const escaped = pat.replace(/[\\.+^$()|[\]{}]/g, "\\$&").replace(/\*\*/g, "__DOUBLESTAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLESTAR__/g, ".*");
|
|
848
|
+
const anchored = escaped.startsWith("~/") ? `(^|/)${escaped.slice(2)}$` : escaped.startsWith("/") ? `^${escaped}$` : `(^|/)${escaped}$`;
|
|
849
|
+
return new RegExp(anchored);
|
|
850
|
+
}
|
|
851
|
+
var COMPILED_PATH_PATTERNS = UNBYPASSABLE_PATH_PATTERNS.map((pattern) => ({
|
|
852
|
+
pattern,
|
|
853
|
+
regex: compileGlobToRegex(pattern)
|
|
854
|
+
}));
|
|
855
|
+
function isPathDenied(path4) {
|
|
856
|
+
const normalized = path4.toLowerCase();
|
|
857
|
+
return COMPILED_PATH_PATTERNS.some((c) => c.regex.test(normalized));
|
|
858
|
+
}
|
|
859
|
+
function isToolDenied(toolName) {
|
|
860
|
+
return UNBYPASSABLE_TOOL_NAMES.includes(toolName);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// src/security/access-constraint-deriver/enforcer.ts
|
|
864
|
+
function checkAccess(toolName, policy, args) {
|
|
865
|
+
if (isToolDenied(toolName)) {
|
|
866
|
+
return {
|
|
867
|
+
decision: "deny",
|
|
868
|
+
reason: `tool "${toolName}" is on the unbypassable deny-tool list`,
|
|
869
|
+
matchedRule: "unbypassable:tool"
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
if (typeof args?.path === "string" && args.path.length > 0 && isPathDenied(args.path)) {
|
|
873
|
+
return {
|
|
874
|
+
decision: "deny",
|
|
875
|
+
reason: `path "${args.path}" is on the unbypassable deny-path list`,
|
|
876
|
+
matchedRule: "unbypassable:path"
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
if (policy.allowedTools === "*") return { decision: "allow" };
|
|
880
|
+
if (policy.allowedTools.includes(toolName)) return { decision: "allow" };
|
|
881
|
+
if (policy.mode === "audit") {
|
|
882
|
+
return {
|
|
883
|
+
decision: "log-and-allow",
|
|
884
|
+
warning: `tool "${toolName}" not in derived policy (audit mode)`
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
decision: "deny",
|
|
889
|
+
reason: `tool "${toolName}" not in derived policy`,
|
|
890
|
+
matchedRule: "allowedTools"
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// src/security/access-constraint-deriver/mcp-guard.ts
|
|
895
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
896
|
+
var accessPolicyStorage = new AsyncLocalStorage2();
|
|
897
|
+
function getActivePolicy() {
|
|
898
|
+
return accessPolicyStorage.getStore();
|
|
899
|
+
}
|
|
900
|
+
function denyToToolResult(decision, requestId) {
|
|
901
|
+
return {
|
|
902
|
+
isError: true,
|
|
903
|
+
content: [
|
|
904
|
+
{
|
|
905
|
+
type: "text",
|
|
906
|
+
text: `access denied: ${decision.reason} (rule: ${decision.matchedRule}, request: ${requestId})`
|
|
907
|
+
}
|
|
908
|
+
]
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// src/security/access-constraint-deriver/chain-adapter.ts
|
|
913
|
+
function toGuardArgs(args) {
|
|
914
|
+
if (typeof args !== "object" || args === null) return void 0;
|
|
915
|
+
const path4 = args["path"];
|
|
916
|
+
return typeof path4 === "string" && path4.length > 0 ? { path: path4 } : void 0;
|
|
917
|
+
}
|
|
918
|
+
function createAccessPolicyChainMiddleware(toolName) {
|
|
919
|
+
return async (args, ctx, next) => {
|
|
920
|
+
const policy = getActivePolicy();
|
|
921
|
+
if (policy === void 0 || policy.mode === "off") {
|
|
922
|
+
return next(args, ctx);
|
|
923
|
+
}
|
|
924
|
+
const decision = checkAccess(toolName, policy, toGuardArgs(args));
|
|
925
|
+
if (decision.decision === "allow") {
|
|
926
|
+
return next(args, ctx);
|
|
927
|
+
}
|
|
928
|
+
if (decision.decision === "log-and-allow") {
|
|
929
|
+
ctx.logger.warn("access-policy: audit violation", {
|
|
930
|
+
tool: toolName,
|
|
931
|
+
warning: decision.warning,
|
|
932
|
+
policySource: policy.source,
|
|
933
|
+
requestId: ctx.requestContext.requestId
|
|
934
|
+
});
|
|
935
|
+
return next(args, ctx);
|
|
936
|
+
}
|
|
937
|
+
ctx.logger.info("access-policy: tool call denied", {
|
|
938
|
+
tool: toolName,
|
|
939
|
+
reason: decision.reason,
|
|
940
|
+
matchedRule: decision.matchedRule,
|
|
941
|
+
policySource: policy.source,
|
|
942
|
+
mode: policy.mode,
|
|
943
|
+
requestId: ctx.requestContext.requestId
|
|
944
|
+
});
|
|
945
|
+
return denyToToolResult(decision, ctx.requestContext.requestId);
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
|
|
798
949
|
// src/mcp/middleware/middleware-chain.ts
|
|
799
950
|
function errorResult(message, requestId) {
|
|
800
951
|
return {
|
|
@@ -939,6 +1090,11 @@ function addTimeoutMiddleware(middlewares, config, skip2) {
|
|
|
939
1090
|
middlewares.push(createTimeoutMiddleware(guard, config.toolName));
|
|
940
1091
|
}
|
|
941
1092
|
}
|
|
1093
|
+
function addAccessPolicyMiddleware(middlewares, config, skip2) {
|
|
1094
|
+
if (skip2.accessPolicy !== true) {
|
|
1095
|
+
middlewares.push(createAccessPolicyChainMiddleware(config.toolName));
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
942
1098
|
function buildMiddlewareStack(config) {
|
|
943
1099
|
const skip2 = config.skip ?? {};
|
|
944
1100
|
const middlewares = [];
|
|
@@ -947,6 +1103,7 @@ function buildMiddlewareStack(config) {
|
|
|
947
1103
|
addRateLimitMiddleware(middlewares, config, skip2);
|
|
948
1104
|
addValidationMiddleware(middlewares, config, skip2);
|
|
949
1105
|
addPolicyMiddleware(middlewares, config, skip2);
|
|
1106
|
+
addAccessPolicyMiddleware(middlewares, config, skip2);
|
|
950
1107
|
addTimeoutMiddleware(middlewares, config, skip2);
|
|
951
1108
|
return middlewares;
|
|
952
1109
|
}
|
|
@@ -12718,4 +12875,4 @@ export {
|
|
|
12718
12875
|
CONSENSUS_VOTE_OUTPUT_SCHEMA,
|
|
12719
12876
|
registerConsensusVoteTool
|
|
12720
12877
|
};
|
|
12721
|
-
//# sourceMappingURL=chunk-
|
|
12878
|
+
//# sourceMappingURL=chunk-6PLFRWIP.js.map
|