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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agents/hermes/policy-permissive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ network_policies:
endpoints:
- host: slack.com
port: 443
path: /api/apps.connections.open
protocol: rest
enforcement: enforce
request_body_credential_rewrite: true
Expand Down
1 change: 1 addition & 0 deletions src/lib/messaging/channels/slack/policy/hermes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ network_policies:
endpoints:
- host: slack.com
port: 443
path: /api/apps.connections.open
protocol: rest
enforcement: enforce
request_body_credential_rewrite: true
Expand Down
17 changes: 11 additions & 6 deletions src/lib/onboard/initial-policy-real-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type PolicyRule = {
type PolicyEndpoint = {
host?: string;
port?: number;
path?: string;
access?: string;
protocol?: string;
enforcement?: string;
Expand Down Expand Up @@ -449,7 +450,7 @@ describe("initial sandbox policy real preset merge", () => {
expect(JSON.stringify(effective)).not.toContain("{sandboxName}");
});

it("materializes separate Hermes Slack bot and app credential bindings", () => {
it("uses a more specific route for the Hermes Slack app credential binding (#10155)", () => {
const sandboxName = "hermes-slack-e2e";
const effective = readPreparedPolicy(
prepareInitialSandboxCreatePolicy(
Expand All @@ -465,11 +466,15 @@ describe("initial sandbox policy real preset merge", () => {
);

expect(slackCom).toHaveLength(2);
expect(slackCom[0]).toMatchObject({
credential_binding: { provider: `${sandboxName}-slack-app` },
rules: [{ allow: { method: "POST", path: "/api/apps.connections.open" } }],
});
expect(slackCom[1]?.credential_binding?.provider).toBe(`${sandboxName}-slack-bridge`);
expect(
slackCom.map((endpoint) => ({
path: endpoint.path,
provider: endpoint.credential_binding?.provider,
})),
).toEqual([
{ path: "/api/apps.connections.open", provider: `${sandboxName}-slack-app` },
{ path: undefined, provider: `${sandboxName}-slack-bridge` },
]);
expect(websocketEndpoints.map((endpoint) => endpoint.credential_binding?.provider)).toEqual([
`${sandboxName}-slack-app`,
`${sandboxName}-slack-app`,
Expand Down
8 changes: 8 additions & 0 deletions test/runtime/policy/permissive-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type SlackEndpoint = {
access?: string;
credential_binding?: { provider?: string };
host?: string;
path?: string;
rules?: Array<{ allow?: { method?: string; path?: string } }>;
};

Expand All @@ -73,6 +74,7 @@ function expectExactHermesSlackCredentialRoutes(endpoints: SlackEndpoint[]): voi
endpoints.map((endpoint) => ({
access: endpoint.access,
host: endpoint.host,
path: endpoint.path,
provider: endpoint.credential_binding?.provider,
routes:
endpoint.rules?.map((rule) => `${String(rule.allow?.method)} ${String(rule.allow?.path)}`) ??
Expand All @@ -82,36 +84,42 @@ function expectExactHermesSlackCredentialRoutes(endpoints: SlackEndpoint[]): voi
{
access: undefined,
host: "slack.com",
path: "/api/apps.connections.open",
provider: "hermes-box-slack-app",
routes: ["POST /api/apps.connections.open"],
},
{
access: "full",
host: "slack.com",
path: undefined,
provider: "hermes-box-slack-bridge",
routes: [],
},
{
access: "full",
host: "api.slack.com",
path: undefined,
provider: "hermes-box-slack-bridge",
routes: [],
},
{
access: "full",
host: "hooks.slack.com",
path: undefined,
provider: "hermes-box-slack-bridge",
routes: [],
},
{
access: undefined,
host: "wss-primary.slack.com",
path: undefined,
provider: "hermes-box-slack-app",
routes: ["GET /**", "WEBSOCKET_TEXT /**"],
},
{
access: undefined,
host: "wss-backup.slack.com",
path: undefined,
provider: "hermes-box-slack-app",
routes: ["GET /**", "WEBSOCKET_TEXT /**"],
},
Expand Down
Loading