Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
gitlab.com/cosban/persistence
A dialect agnostic database driver extension to provide simplified query and transaction execution
Created for the sake of learning and memes
Open the connection to your database and specify which driver you will be using. Currently only postgres the postgres driver is written.
import (
_ "gitlab.com/cosban/persistence/postgres"
"gitlab.com/cosban/persistence"
)
func main() {
var connectionTemplate = "postgres://%s:%s@%s:%d/%s?sslmode=%s"
c, err := persistence.Open(
"postgres",
fmt.Sprintf(connectionTemplate, username, password, host, port, database, sslmode),
)
}
persistence can perform both raw, and built up queries.
// raw
var actualText string
query := persistence.Prepare("SELECT value FROM raw_example")
err := c.RawStatement().QueryRow(query, &actualText)
// builder
type Object struct {
Value string
}
var actual Object
err := c.BuildStatement().Query(&actual)
If a query is too complicated to easily build within the query builder, it is very simple to write and execute your own queries within a prepared statement.
// single row
var value1 string
var value2 string
statement := persistence.Prepare("SELECT value1, value2 FROM raw_example LIMIT 1")
err := c.RawStatement().QueryRow(query, &value1, &value2)
if err != nil {
panic(err)
}
fmt.Println(value1, value2)
// multiple rows
statement := persistence.Prepare("SELECT value1, value2 FROM raw_example LIMIT 1")
rows, err := c.RawStatement().Query(query)
if err != nil {
panic(err)
}
defer rows.Close()
for rows.Next() {
var value string
err = rows.Scan(&value)
if err != nil {
panic(err)
}
fmt.Println(value)
}
Either execute your transactions, i.e. your inserts, updates, deletes, Or your queries which return data.
For single statement operations, you may prepare and execute/query in one step using the PrepareAnd... methods available
from your connection. You can either query for a single row, or multiple. It's up to you.
// raw
statement := persistence.Prepare("INSERT INTO raw_example (value) VALUES ($1)", "beep boop")
err := persistence.RawStatement().ExecuteStatements(statement)
// builder
type Object struct {
Value string
}
actual := Object{"beep boop"}
err := c.BuildStatement().Insert(actual)
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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.