
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
curlconverter
Advanced tools
Transpile curl
commands into C, C#, ColdFusion, Clojure, Dart, Elixir, Go, HTTPie, Java, JavaScript, Julia, Kotlin, Lua, MATLAB, Objective-C, OCaml, Perl, PHP, PowerShell, Python, R, Ruby, Rust, Swift, Wget, Ansible, HAR, HTTP or JSON.
Try it on curlconverter.com or as a drop-in curl
replacement:
$ curlconverter --data "hello=world" example.com
import requests
data = {
'hello': 'world',
}
response = requests.post('http://example.com', data=data)
Features:
-O -v -X POST
to -OvXPOST
--data @filename
generates code that reads that file and @-
reads stdinLimitations:
-L
/--location
/--no-location
, the generated code will not handle redirects the same way as the curl commandcurl $VAR
can do anything, depending on what's in $VAR
. curlconverter assumes that environment variables don't contain characters that would affect parsingcurl $(echo example.com)
work, more complicated subcommands (such as nested commands or subcommands that redirect the output) won't generate valid codeInstall the command line tool with
npm install --global curlconverter
Install the JavaScript library for use in your own projects with
npm install curlconverter
curlconverter requires Node 12+.
curlconverter
acts as a drop-in replacement for curl. Take any curl command, change "curl
" to "curlconverter
" and it will print code instead of making the request
$ curlconverter example.com
import requests
response = requests.get('http://example.com')
To read the curl command from stdin, pass -
$ echo 'curl example.com' | curlconverter -
import requests
response = requests.get('http://example.com')
Choose the output language by passing --language <language>
. The options are
ansible
c
cfml
clojure
csharp
dart
elixir
go
har
http
httpie
java
, java-httpurlconnection
, java-jsoup
, java-okhttp
javascript
, javascript-jquery
, javascript-xhr
json
julia
kotlin
lua
matlab
node
, node-http
, node-axios
, node-got
, node-ky
, node-request
, node-superagent
objc
ocaml
perl
php
, php-guzzle
, php-requests
powershell
, powershell-webrequest
python
(the default), python-http
r
, r-httr2
ruby
, ruby-httparty
rust
swift
wget
--verbose
enables printing of conversion warnings and error tracebacks.
The JavaScript API is a bunch of functions that can take either a string of Bash code or an array of already-parsed arguments (like process.argv
) and return a string with the resulting program:
import * as curlconverter from 'curlconverter';
curlconverter.toPython('curl example.com');
curlconverter.toPython(['curl', 'example.com']);
// "import requests\n\nresponse = requests.get('http://example.com')\n"
Note: add "type": "module",
to your package.json for the import
statement above to work. curlconverter must be imported as an ES module with import
this way and not with require()
because it uses top-level await
.
There's a corresponding set of functions that also return an array of warnings if there are any issues with the conversion:
curlconverter.toPythonWarn('curl ftp://example.com');
curlconverter.toPythonWarn(['curl', 'ftp://example.com']);
// [
// "import requests\n\nresponse = requests.get('ftp://example.com')\n",
// [ [ 'bad-scheme', 'Protocol "ftp" not supported' ] ]
// ]
If you want to host curlconverter yourself and use it in the browser, it needs two WASM files to work, tree-sitter.wasm
and tree-sitter-bash.wasm
, which it will request from the root directory of your web server. If you are hosting a static website and using Webpack, you need to copy these files from the node_modules/ directory to your server's root directory in order to serve them. You can look at the webpack.config.js for curlconverter.com to see how this is done. You will also need to set {module: {experiments: {topLevelAwait: true}}}
in your webpack.config.js.
There's a VS Code extension that adds a "Paste cURL as <language>" option to the right-click menu: https://marketplace.visualstudio.com/items?itemName=curlconverter.curlconverter. It doesn't support the same languages, curl arguments or Bash syntax as the current version because it has to use an old version of curlconverter.
See CONTRIBUTING.md
MIT © Nick Carneiro
FAQs
convert curl commands to Python, JavaScript, Go, PHP and more
We found that curlconverter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.