Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
= HttpHeaders
HttpHeaders is a library for parsing HTTP-compliant header strings. It was designed to process the results from the header_str method on Curl::Easy objects in Ruby, but should work for other HTTP-compliant string formats.
It correctly parses the content type, response code and most other key-value fields from the HTTP response header, including keys that may appear multiple times in the header such as Set-Cookie.
While parsing these header strings seems a very easy thing to do, the small variances in HTTP server responses make it more challenging to process these strings than it may initially appear. This library tries to account for these server variances by including a comprehensive test suite of HTTP header strings that the library has been tested against.
== Installation
Set up your machine to pull gems from gems.github.com if you haven't already. Then:
sudo gem install jsl-http_headers
== Quick Start
Just require the library, create a new HttpHeaders object with the header string and start invoking methods.
require 'http_headers' h = HttpHeaders.new(header_str) h.content_type h.etag h.set_cookie # Will return an Array of String values if more than one match is found
Other methods should just work for arbitrary attributes by lowercasing the attribute name and substituting hyphens with underscores.
== Implementation Notes
HttpHeaders uses ruby's +method_missing+ in order to build queries for the given parameter dynamically, so it doesn't need to parse values for every field at the time that the HttpHeader object is instantiated with a HTTP header string.
== Possible Limitations
Some attributes, such as Set-Cookie, may appear listed multiple times in the header. Where this occurs, we try to find all instances of the key and return an Array if multiple occurrences are found. Otherwise, nothing is done in the case where there are multiple values for a cookie given as values of a particular key - at this point the values won't be magically turned into an Array and it will be up to the user to program the desired behavior in a client library.
== Feedback
Please write the author if you have any questions or feedback about this library. Patches are welcome if you have ideas about how the behavior of HttpHeaders can be improved for particular cases. Please include specs using the associated test suite if you make improvements, and I would also be happy to receive more fixtures consisting of HTTP strings of failure cases indicating where the library can be improved.
== References
== Author
Justin S. Leitgeb, justin@phq.org
FAQs
Unknown package
We found that jsl-http_headers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.