Skip to content

Add library stubs for the taints of amphp/http-client, byte-stream, file and process, and amp's delay() - #12482

Merged
danog merged 3 commits into
vimeo:masterfrom
danog:amphp-library-stubs
Oct 26, 2026
Merged

danog merged 3 commits into
vimeo:masterfrom
danog:amphp-library-stubs

Conversation

@danog

@danog danog commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Library stubs (stubs/libraries/amphp/*.phpstub) for the amphp packages:

  • amphp/http-client 5: the URI of a Request (constructor and setUri()) is an SSRF sink, the path Form::addFile() uploads a file sink; the headers (getHeaders(), getHeaderArray(), getHeader()) and the body (getBody()) of a Response are input sources.
  • amphp/byte-stream 2: Payload::read(), buffer() and __toString() return what the payload holds (@psalm-flow ($this) -> return), so the body of a response taints what is read from it.
  • amphp/file 3: the paths of its functions (openFile(), read(), write(), deleteFile(), move(), createSymlink(), ...) are file sinks.
  • amphp/process 2: the command Process::start() runs is a shell sink.
  • amphp/amp 3: delay() does I/O (@psalm-capabilities io), as usleep() does: it suspends the fiber and runs the event loop meanwhile.

The response sources are declared on Amp\Http\Client\Response itself rather than on the amphp/http HttpMessage it inherits the header methods from, or on byte-stream's Payload: those also hold the messages and streams the code builds itself, which would all become sources. A payload is only tainted when it comes from a source, such as Response::getBody().

The amp and file stubs declare functions only, so they need #12481 to be loaded; this PR is stacked on it and on #12480 (for LibraryStubsTestCase::getReportedIssueTypePrefixes(), used by the delay() case).

Tests: AmphpHttpClientLibraryStubsTest (http-client, byte-stream, process) and AmphpLibraryStubsTest (amp, file). They are two classes because the declarations of the functions must not share a file with classes the stubs extend: a stub's parent queues its file again, which then redeclares the functions over the stub's.

Inline PRs for the libraries: amphp/http-client#402 and amphp/http-client#403, amphp/byte-stream#118, amphp/file#102, amphp/process#87.

@danog danog added the release:feature The PR will be included in 'Features' section of the release notes label Oct 23, 2026
@danog
danog merged commit 74e716f into vimeo:master Oct 26, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:feature The PR will be included in 'Features' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant