Skip to content

Mattermost: guard probe fetches#58529

Merged
jacobtomlinson merged 1 commit into
mainfrom
unknown repository
Apr 2, 2026
Merged

Mattermost: guard probe fetches#58529
jacobtomlinson merged 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Mar 31, 2026

Copy link
Copy Markdown

Summary

  • routes Mattermost account probes through the shared SSRF guard instead of raw fetch
  • threads the existing allowPrivateNetwork account setting into probe requests
  • updates probe tests and the unreleased changelog entry for the probe path

Changes

  • updated extensions/mattermost/src/mattermost/probe.ts to call fetchWithSsrFGuard with a dedicated audit context and proper release handling
  • updated extensions/mattermost/src/channel.ts to pass allowPrivateNetwork into probe calls
  • updated extensions/mattermost/src/mattermost/probe.test.ts to mock the guard directly and cover policy forwarding
  • added an Unreleased fix note to CHANGELOG.md

Validation

  • Ran pnpm test -- extensions/mattermost/src/mattermost/probe.test.ts
  • Ran pnpm test -- extensions/mattermost/src/channel.test.ts
  • Ran pnpm check after rebasing onto latest origin/main; it still fails on unrelated pre-existing TypeScript issues in extensions/openai, extensions/openrouter, and src/agents/skills*
  • Verified the probe path no longer uses raw fetch() and now routes through fetchWithSsrFGuard
  • Ran local agentic review via claude -p "/review"; it did not review the workspace diff and instead prompted for an open PR number, so I relied on the focused local tests above

Notes

  • Residual risk or follow-up: repo-wide pnpm check is not green on latest origin/main because of the unrelated TypeScript issues listed above

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost size: S labels Mar 31, 2026
@greptile-apps

greptile-apps Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR routes Mattermost account probes through the shared fetchWithSsrFGuard helper instead of raw fetch, and threads the allowPrivateNetwork account setting into probe requests. The implementation is clean and correct.

  • probe.ts wraps the response-processing logic in a nested try/finally that calls release(), ensuring the guard's dispatcher is always cleaned up on both success and error paths.
  • The outer finally correctly clears the probe's own AbortController timer regardless of outcome.
  • channel.ts safely forwards account.config.allowPrivateNetwork === true (explicit boolean check) to prevent any truthy non-boolean leaking into the policy.
  • Tests are well-structured: they mock fetchWithSsrFGuard at the module level with vi.hoisted, verify release is called on all response paths, and add a focused test for the allowPrivateNetwork → policy forwarding.
  • Minor note: the PR description states a CHANGELOG.md entry was added, but the committed diff does not include any CHANGELOG.md change — this is a description inaccuracy with no functional impact.

Confidence Score: 5/5

Safe to merge — the SSRF guard is correctly integrated with proper resource cleanup on all code paths.

All three changed files are correct: release() is called in a finally block, the abort timer is cleaned up in the outer finally, allowPrivateNetwork is forwarded safely, and the tests cover success, error-response, throw, and policy-forwarding paths. The one P2 comment is a minor test-documentation gap that does not affect correctness or security.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/mattermost/src/mattermost/probe.test.ts
Line: 114-126

Comment:
**Missing `release` assertion on throw path**

The "returns fetch error when request throws" test uses `mockFetchGuard.mockRejectedValueOnce(...)`, so no `{ response, release }` is returned and no caller-side `release` call is expected — this is correct by design. However, it might be worth adding a negative assertion (`expect(mockRelease).not.toHaveBeenCalled()`) to explicitly document and guard that invariant, similar to how the success-path tests assert `toHaveBeenCalledTimes(1)`. Without it, a future regression that accidentally returns a release handle before throwing could go undetected.

```suggestion
    await expect(probeMattermost("https://mm.example.com", "token")).resolves.toEqual(
      expect.objectContaining({
        ok: false,
        status: null,
        error: "network down",
      }),
    );
    expect(mockRelease).not.toHaveBeenCalled();
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "Mattermost: guard probe fetches" | Re-trigger Greptile

@ghost

ghost commented Mar 31, 2026

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ghost

ghost commented Apr 1, 2026

Copy link
Copy Markdown
Author

@codex review

@ghost

ghost commented Apr 1, 2026

Copy link
Copy Markdown
Author

@greptile review

@jacobtomlinson
jacobtomlinson merged commit 2eaf5a6 into openclaw:main Apr 2, 2026
42 checks passed
ngutman pushed a commit that referenced this pull request Apr 3, 2026
steipete pushed a commit to duncanita/openclaw that referenced this pull request Apr 4, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants