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.
github.com/genjidb/genji
ChaiSQL is a modern embedded SQL database, focusing on flexibility and ease of use for developers. It provides a fresh alternative to traditional embedded databases by offering advanced features tailored for modern applications.
ChaiSQL is work in progress and is not ready yet for production.
Here is a high level list of features that we want to implement in the near future, in no particular order:
Install the ChaiSQL database
go install github.com/chaisql/chai
package main
import (
"context"
"fmt"
"log"
"github.com/chaisql/chai"
)
func main() {
// Create a database instance, here we'll store everything on-disk
db, err := chai.Open("mydb")
if err != nil {
log.Fatal(err)
}
defer db.Close()
// Create a table.
// Notice that it is possible to define constraints on nested columns.
err = db.Exec(`
CREATE TABLE user (
id INT PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL,
address (
city TEXT DEFAULT "unknown",
zipcode TEXT
),
friends ARRAY,
CHECK len(friends) > 0
)
`)
err = db.Exec(`
INSERT INTO user (id, name, age, address, friends)
VALUES (
11,
'Foo2',
20,
{city: "Lyon", zipcode: "69001"},
["foo", "bar", "baz"]
)`)
// Go structures can be passed directly
type User struct {
ID uint
Name string
TheAgeOfTheUser float64 `chai:"age"`
Address struct {
City string
ZipCode string
}
}
// Let's create a user
u := User{
ID: 20,
Name: "foo",
TheAgeOfTheUser: 40,
}
u.Address.City = "Lyon"
u.Address.ZipCode = "69001"
err = db.Exec(`INSERT INTO user VALUES ?`, &u)
// Query data
rows, err := db.Query("SELECT id, name, age, address FROM user WHERE age >= ?", 18)
defer rows.Close()
err = rows.Iterate(func(r *chai.Row) error {
err = r.Scan(...)
err = r.StructScan(...)
err = r.MapScan(...)
return nil
})
}
Checkout the Go doc and the usage example in the README to get started quickly.
For in-memory operations, simply use :memory:
:
db, err := chai.Open(":memory:")
// import chai as a blank import
import _ "github.com/chaisql/chai/driver"
// Create a sql/database DB instance
db, err := sql.Open("chai", "mydb")
if err != nil {
log.Fatal(err)
}
defer db.Close()
// Then use db as usual
res, err := db.ExecContext(...)
res, err := db.Query(...)
res, err := db.QueryRow(...)
// use the driver.Scanner to scan into a struct
var u User
err = res.Scan(driver.Scanner(&u))
The chai command line provides an SQL shell for database management:
go install github.com/chaisql/chai/cmd/chai@latest
Usage example:
# For in-memory database:
chai
# For disk-based database:
chai dirName
Contributions are welcome!
A big thanks to our contributors!
Made with contrib.rocks.
For any questions or discussions, open an issue.
FAQs
Unknown package
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.