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.
Allow to fetch data from a civicrm server. It covers all the entities civicrm api4 exposes and the basic crud methods. Yes, it can create, update or delete too. Yes, it can chain api calls, the whole magic.
It's assumed you are familiar with the civicrm api, checkout the documentation if you aren't sure.
$npm install civicrm
const config = {
server:'http://example.org',
//path: if not under /civicrm/ajax/rest/api4
//key:'your key from settings.civicrm.php', mostly not needed
api_key:'the user key'
};
const crmAPI = require('civicrm')(config);
const results = await this.crmAPI.get("Contact", {
select: [
"first_name",
"last_name",
"display_name",
"phone_primary.phone",
"email_primary.email",
"address_primary.country_id:abbr",
"address_primary.postal_code",
"address_primary.city",
"address_primary.street_address",
],
limit: 25,
});
results.values.forEach ( (val: any) =>
console.log(val.id +": "+val.display_name+ " "+val['email_primary.email']+ " "+ val["phone.primary.phone"])
);
const r = await crmAPI.create ('Contact',{
values: {
first_name: contact.firstName,
last_name: contact.lastName || null,
//external_identifier: contact.contactRef, // creates problems if the contact exists in trash
source: source,
}});
console.log(r);
const result = await crmAPI.delete ('contact',{where: [["id", "=", 42]]}),
if (result.is_error) {
console.log('ERROR '+ result.error_message);
} else {
console.log('DELETED CONTACT '+ result.id);
}
);
All the above actions relies on the lower level API4 method. You can call it directly if there is another action you need. For instance the get above can also be called:
const result = await crmAPI.api4 ('Contact','get',{...});
all the features of API4 are available, including the 4th parameter "index", for instance to format the list of countris as a map with the iso code being the key and the id the value:
const countries = await this.crmAPI.get(
"Country",
{
select: ["id", "iso_code", "row_count"],
limit: 9999,
},
{ iso_code: "id" }
);
PR welcome!
FAQs
Access civicrm api4 (using REST)
We found that civicrm demonstrated a healthy version release cadence and project activity because the last version was released less than 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.