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.
If you're using the latest version (and always updating when possible), be very carefull, because I'm going to change a lot of things preparing for 0.2.0. Here's some of the planned changes:
Node-ORM is a NodeJS module for multiple databases using Object-Relational Mapping with some cool features like validators and hooks. New features are added by suggestion issues or when I remember I need something. I make a strong effort not to change the API, but sometimes it can happen. If you don't want to get into trouble I suggest you to define your package.json (in project) to use a specific version of ORM (and not >= x.y.z).
Install using NPM:
npm install orm
You can check the API for a more detailed overview.
var orm = require("orm");
var db = orm.connect("mysql://username:password@hostname/database", function (success, db) {
if (!success) {
console.log("Could not connect to database!");
return;
}
// you can now use db variable to define models
});
var orm = require("orm");
var mysql = require("mysql");
var client = mysql.createClient({
user: 'root',
password: 'root'
});
var db = orm.connect("mysql", client, function (success, db) {
// same as above...
});
This allows you to generate your own database objects that conform to the following postgres and mysql libraries:
var Person = db.define("person", {
"name" : { "type": "string" },
"surname": { "type": "string", "default": "" },
"age" : { "type": "int" }
}, {
"methods" : {
"fullName" :function () {
return this.name + " " + this.surname;
}
}
});
Person.hasOne("father", Person);
// or just
Person.hasOne("mother"); // defaults to same model
Person.hasMany("friends", Person, "friend"); // will create a table "person_friends" with 2 fields (person_id and friend_id)
Person.sync();
Note: sync()
only creates tables at the moment; table modifications will be added in an upcoming version.
var John = new Person({
"name" : "John",
"surname" : "Doe",
"age" : 20
});
console.log("Hello, my name is " + John.fullName() + " and I'm " + John.age + " years old");
John.save(function (err, JohnCopy) {
if (!err) {
console.log("Saved! ID=" + John.id); // you can use John or JohnCopy
} else {
console.log("Something went wrong...");
console.dir(err);
}
});
I think an example is better to explain.
John.setFather(Jeremy, function () {
John.setMother(Jane, function () {
John.addFriends(Jeremy, Jane, function () {
console.log("Jeremy and Jane (John's parents) are now his friends too");
});
});
});
If you want there's also this methods:
John.getFather(function (JohnFather) {
console.log("John's father is " + JohnFather.name);
});
John.unsetMother(function () {
console.log("John has no mother now!");
});
John.removeFriends(Jeremy, Jane, function () {
console.log("John has no friends now!");
});
// or just don't send any, all will be removed
John.removeFriends(function () {
console.log("John has no friends now!");
});
Currently this module supports the following database types:
This values are still just supported for .sync() (table creations), not for other instance operations like .save() (yet).
Name | Description | MySQL Type | PostgreSQL Type | MongoDB Type |
---|---|---|---|---|
string | Small text | VARCHAR(255) | VARCHAR(255) | String |
text | Big text | TEXT | TEXT | String |
int, integer, num, number | Signed integer | INT | INTEGER | Int |
float | Floating point number | FLOAT | REAL | Float |
bool, boolean | True or false value | TINYINT(1) (true=1, false=0) | BOOLEAN | Boolean |
date | Date/time value (seconds precision) | DATETIME | TIMESTAMP | ? |
data | Binary data | BLOB | BYTEA | String |
enum | Enumerated value | ENUM | ENUM | String |
struct, object | Generic (and simple) object | TEXT (saved as JSON) | TEXT (saved as JSON) | Object |
FAQs
NodeJS Object-relational mapping
The npm package orm receives a total of 639 weekly downloads. As such, orm popularity was classified as not popular.
We found that orm demonstrated a not healthy version release cadence and project activity because the last version was released 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
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.