Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Using a yaml configuration you can transform a payload to another payload. Example:
# config.yaml
payload:
id:
$field: _id
$formatter: to_integer
user_name:
$field: name
login_type:
$field: login_provider
$map:
google: GOOGLE
twitter: TWITTER
auth0: APP
country:
$fnc: get_country
Input:
// internal_payload.json
{
"_id": 1,
"name": "Jhon Doe",
"login_provider": "auth0"
}
translator = PayloadTranslator::Service.new(config)
external_payload = translator.translate(internal_payload)
Return:
// external_payload.json
{
"id": "1",
"user_name": "Jhon Doe",
"login_type": "APP"
}
Resolve the field output with a custom function.
PayloadTranslator.configure do |config|
config.handlers = {
get_country: ->(payload) { payload['name'] },
}
end
Or per service
PayloadTranslator::Service(config, handlers: get_country: ->(payload) { payload['name'] })
Apply different formatters to the output.
PayloadTranslator.configure do |config|
config.formatters = {
uppercase: ->(value) { value.upcase },
to_integer: ->(value) { value.to_i },
}
end
Or formatter per service
PayloadTranslator::Service(config, formatters: to_integer: ->(value) { value.to_i })
Store adapter configuration
PayloadTranslator.configure do |config|
config.adapters_configurations = {
internal_to_external: {
"payload" => {
"id" => { "$field" => "_id" }
}
}
}
end
translator = PayloadTranslator::Service.new(:internal_to_external)
translator = PayloadTranslator::ServiceMultiple.new([:internal_to_external, :external_to_internal])
translated_response = translator.translate({"user_id" => 4 }) do |translated_payload|
response = Net::HTTP.post_form(
URI("https://jsonplaceholder.typicode.com/todos"),
translated_payload
).body
JSON.parse(response)
end
Translate all array items, use $field_for_all_items
special propery of the first elemtn of the array to apply the same translation from the same field
Config:
payload:
countries:
- $field_for_all_items: countries
name:
$field: 'name'
Input:
{
"countries": [
{
"name": "US",
"code": "US_CODE"
},
{
"name": "AU",
"code": "AU_CODE"
}
]
}
Result:
{
"countries": [
{
"name": "US"
},
{
"name": "AU"
}
]
}
FAQs
Unknown package
We found that payload-translator 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.