18 Commits

Author SHA1 Message Date
Sam Morrow c195fb9fea fix(raw): reject dot-dot segments revealed by decoding encoded separators
rejectPathTraversal split components on literal "/" before checking
each segment, so a segment containing an encoded separator (e.g.
"%2e%2e%2fsecret.txt") decoded to "../secret.txt" instead of "..", and
the check never caught it. Percent-decoding a segment can therefore
introduce new "/"-separated subsegments that were invisible to the
original literal split.

Recursively re-split and re-check the decoded form whenever decoding
changes a segment, so a ".." revealed by one or more layers of
percent-decoding (including through an encoded separator, or
double-encoding) is rejected regardless of where it appears.

Add regression tests for encoded-separator traversal, encoded
separators in other components, and double percent-encoded dot-dot
segments, plus a benign percent-encoded filename case to confirm
non-traversal decodes still pass through.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-19 15:22:51 +02:00
Sam Morrow 51ea58e70b fix(raw): reject traversal segments when constructing raw content URLs
url.URL.JoinPath normalizes ".." segments before producing the final
URL. A path containing enough parent-directory segments could
therefore consume the owner, repo, and ref components already joined
onto the base URL, rebinding the raw.githubusercontent.com request to
a different owner/repository/ref than the caller specified.

Reject any owner, repo, ref/sha, or path component whose "/"-separated
segments are, or percent-decode to, ".." before building the URL.
Benign filenames such as "file..txt" or "..hidden" are unaffected.

URLFromOpts, refURL, and commitURL now return an error alongside the
URL string so this can be enforced at construction time; GetRawContent
propagates it. Adds table-driven tests covering normal, nested, and
benign double-dot paths as well as literal and percent-encoded
traversal attempts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-19 15:22:51 +02:00
Tommaso Moro 778f5bb6a3 chore(deps): bump go-github v87 → v89 and resolve breaking changes (#2840)
* chore(deps): bump go-github v87 -> v89 and resolve breaking changes

Bumps google/go-github from v87 to v89 across the module and fixes the
resulting breaking changes. No tool or behavior changes.

- Rewrite all import paths go-github/v87 -> go-github/v89.
- gists.go: Gists.Create now takes CreateGistRequest by value and
  Gists.Edit is renamed to Gists.Update taking UpdateGistRequest.
- repositories_test.go: adapt to RepositoryRelease fields that became
  value types in v89 (ID, TagName, Draft).
- Regenerate third-party license files for the new module path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Don't clear gist description on update when omitted

update_gist always sent Description as a pointer to the OptionalParam
zero value (""), so omitting description would overwrite an existing gist
description with an empty string. Only set UpdateGistRequest.Description
when the caller actually provided the argument; an explicit empty string
still clears it. Adds a test asserting the description key is absent from
the PATCH body when omitted and present when set.

This addresses a pre-existing behavior surfaced while migrating to the
v89 gist request types.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-07-08 15:08:59 +01:00
Iulia Bejan 1861a351f8 Upgrade go-github from v82 to v87 (#2452)
Breaking changes addressed:
- raw.NewClient: Use WithHTTPClient/WithEnterpriseURLs options, pass ctx to
  NewRequest, return (*Client, error)
- internal/ghmcp/server.go: Use functional options for REST client creation,
  replace UserAgent field mutation with UserAgentTransport wrapper, add
  restUATransp field to githubClients struct
- pkg/github/dependencies.go: Use functional options for REST client creation,
  handle raw.NewClient error return
- pkg/github/actions.go: Handle new WorkflowDispatchRunDetails return value
  from CreateWorkflowDispatchEventByID/ByFileName
- pkg/github/issues.go: Replace IssueListOptions with ListOptions for
  SubIssue.ListByIssue
- pkg/github/notifications.go: MarkThreadDone now takes string instead of
  int64; remove ParseInt and strconv import
- pkg/github/projects.go: Remove pointer indirection from
  ListProjectsPaginationOptions and ListProjectsOptions fields
- pkg/github/issues_granular.go: Pass ctx to NewRequest, remove ctx from Do
- Test files: Add mustNewGHClient helper, replace all NewClient calls,
  fix stubClientFnFromHTTP signature, fix lockdown_test.go BaseURL handling,
  fix raw_test.go, remove invalid threadID test case

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-18 14:36:23 +02:00
Oleksandr Redko 505d5dc33a refactor: modernize code with modernize and intrange 2026-02-12 12:58:49 +01:00
JoannaaKL 266bd9311e Gogithub update (#2004)
* Bump google/go-github

* chore: regenerate license files

Auto-generated by license-check workflow

* Fix required block

* Go mod vendor and tidy again

* Remove unused fatih/color dependency to fix CI (#2005)

* Initial plan

* Remove unused github.com/fatih/color dependency

The fatih/color package was listed in go.mod but not actually imported
or used anywhere in the codebase. This caused the CI "go mod tidy -diff"
check to fail. Running go mod tidy removed:
- github.com/fatih/color v1.18.0
- github.com/mattn/go-colorable v0.1.13 (transitive)
- github.com/mattn/go-isatty v0.0.20 (transitive)

Fixes the failing ubuntu-latest workflow build.

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
2026-02-12 11:04:54 +01:00
Copilot 80b0306557 Replace go-github-mock with stretchr/testify for actions/issues/projects tests (#1737)
* Initial plan

* migrate tests from go-github-mock to internal testify-based mock

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* address feedback in testmock helper

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* tweak testmock path matching edge case

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* refine testmock options and path matching

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* simplify matchPath and document delete endpoint

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* Replace go-github-mock usage in tests with shared HTTP mock helper

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* Replace go-github-mock usage in tests with shared HTTP mock helper

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* fix tests and lint after mock cleanup

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* Remove import completely

* Partial removal in repositories_test.go

* Final removal

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Co-authored-by: JoannaaKL <joannaakl@github.com>
2026-01-06 10:45:29 +01:00
copilot-swe-agent[bot] 3b9a0b1f52 Fix linting issues in helper constants
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
2025-12-18 15:31:19 +01:00
copilot-swe-agent[bot] b81df990fd Migrate actions, dependabot, and secret_scanning tests to testify
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
2025-12-18 15:31:19 +01:00
copilot-swe-agent[bot] 12af99b48c Add endpoint constants and migrate raw package tests
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
2025-12-18 15:31:19 +01:00
Jonathan c73f06fa29 bumps google/go-github to v79 2025-11-15 22:07:38 +01:00
Jonathan cf0e05e300 Update to google/go-github@v77 (#1357)
* update to google/go-github@v77

* licences update from required CI build

* fixes licences

* fixes possible nil reference

* refresh licences due to recent conflicts

---------

Co-authored-by: Roberto Nacu <kerobbi@github.com>
2025-11-07 08:06:27 -08:00
Jonathan 6f5040734a Updates github-mcp-server to go-github/v76 (#1289)
* updates github-mcp-server to go-github/v76

* updates license files

* refactors ListProjects to make use of
google/go-github ProjectsService

* refactors GetProject to make use of google/go-github ProjectsService

* declaring commit without a pointer

* cleanup additional commit pointer

---------

Co-authored-by: Tommaso Moro <37270480+tommaso-moro@users.noreply.github.com>
2025-10-27 13:53:53 +01:00
Tommaso Moro 521d5e9258 Bump go-github to v74 (#826)
* update all imports to use v74

* go mod tidy

* update third party licenses

* rename

* autogen licenses
2025-08-06 22:11:50 +01:00
Martin Høst Normark be91795fd3 Bump go-github to v73.0.0 (#597)
* Bump go-github to v73.0.0

* Clean up go.mod and update licenses

* Updated remaining imports to use github package v73 instead of v72

---------

Co-authored-by: Tommaso Moro <37270480+tommaso-moro@users.noreply.github.com>
Co-authored-by: tommaso-moro <tommaso-moro@github.com>
2025-07-15 15:21:24 +01:00
JoannaaKL 5904a0365e Fix linting flow (#614)
* Add issues type filter

* Add e2e test

* Update e2e/e2e_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add lint script and update golangci config

* Add lint script

* Install if not installed

* Pass lint config

* Use action and rename workflow

* Back to reparate config

* Migrate config to v2

* Update config

* Lint code

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-30 15:14:45 +02:00
Roberto Nacu 271138452f add ctx propagation to raw api call 2025-06-23 14:55:19 +02:00
Sam Morrow 3e32f75cf4 fix: use better raw file handling and return resources 2025-06-12 14:54:23 +02:00