Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prism proxy modifying files #2349

Open
Freeshnik opened this issue Aug 7, 2023 · 3 comments
Open

Prism proxy modifying files #2349

Freeshnik opened this issue Aug 7, 2023 · 3 comments

Comments

@Freeshnik
Copy link

Freeshnik commented Aug 7, 2023

Inb4 thank you for great tool!

Issue Description:
When using the Prism proxy to proxy requests to another backend, it has been observed that the library is modifying files during the proxy process.
This behavior is unexpected and can lead to validation errors.

Steps to Reproduce:

Choose a Prism version v5.2.0.
Set up a proxy configuration to forward requests to a target backend server (e.g., http://backend.example.com).
Initiate a request to the proxy server, providing a URL that should be forwarded to the backend.
Monitor the content of the files that are being proxied and compare them to the original content.

Expected Behavior:
The library should act as a transparent proxy, forwarding requests to the target backend without altering the content of the files being proxied.
The files received from the backend should remain unchanged and identical to the original files.

Actual Behavior:
During the proxy process, the library is modifying the content of the files being proxied.
File comparison functions (utilizing PHP's built-in functions) indicate disparate hashes between files. Moreover, methods for retrieving Mime-Type yield distinct outcomes. For instance, the original file, characterized by the Mime-Type 'application/vnd.ms-excel' (denoting an .xls file), undergoes a transformation during proxying, resulting in a Mime-Type alteration to 'application/octet-stream'.
Additionally, there is a discrepancy in file sizes. In the original context, the file has a size of 7680 bytes, whereas after passing through the Prism proxy, its size increases to 10942 bytes.

Impact:

Validation problems: File not pass validation rules based on mime-type.
Data Corruption: The modifications introduced by the library during proxying can lead to data corruption, making the proxied content unusable or inconsistent with the original data.

Additional Information:

Library Version: v5.2.0

Workaround:
At this time, there is no known workaround to prevent the library from modifying files during the proxy process.
Users are advised to avoid using the proxy functionality of the affected library until the issue is resolved.

Proposed Solution:
Investigate the codebase of the library to identify the root cause of the file modifications during the proxy process. Implement a fix that ensures the content of proxied files remains unchanged when passed through the proxy.

Environment:
OS Ubuntu 20.04
PHP programming language to validate hash values and ascertain Mime-Types.

@EdVinyard
Copy link
Contributor

@Freeshnik , thanks for your report. At this time, Prism doesn't support binary data in either mock or proxy mode. However, we agree that it should and welcome PRs, especially for the easier proxy case.

Copy link

This ticket has been labeled jira. A tracking ticket in Stoplight's Jira (STOP-363) has been created.

@gnanendra-bogireddy
Copy link

Hi @EdVinyard is there any progress on the above issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants