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/benjamin658/influx-query-builder
The super lightweight InfluxDB query builder implemented in Go.
go get -u github.com/benjamin658/influx-query-builder
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement).
Build()
Output:
SELECT "temperature","humidity" FROM "measurement"
builder := New()
query := builder.
Select("temperature AS temp", "humidity AS hum").
From("measurement).
Build()
Output:
SELECT "temperature" AS "temp","humidity" AS "hum" FROM "measurement"
builder := New()
query := builder.
Select(`MEAN("temperature")`, `SUM("humidity")`).
From("measurement").
Build()
Output:
SELECT MEAN("temperature"),SUM("humidity") FROM "measurement"
builder := New()
query := builder.
Select(`MEAN("temperature") AS mt`, `SUM("humidity") AS sh`).
From("measurement").
Build()
Output:
SELECT MEAN("temperature") AS "mt",SUM("humidity") AS "sh" FROM "measurement"
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
Where("time", ">", "2018-11-01T06:33:57.503Z").
And("time", "<", "2018-11-02T09:35:25Z").
Or("tag", "=", "t").
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z' OR "tag" = 't'
Noted: If you use Where
with WhereBrackets
, Where
will override the WhereBrackets
.
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
WhereBrackets(
// Passing a new builder as the param
New().
Where("time", ">", "2018-11-01T06:33:57.503Z").
And("time", "<", "2018-11-02T09:35:25Z").
).
Or("tag", "=", "t").
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" WHERE ("time" > '2018-11-01T06:33:57.503Z' AND "time" < '2018-11-02T09:35:25Z') OR "tag" = 't'
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
Where("time", ">", "2018-11-01T06:33:57.503Z").
AndBrackets(
// Passing a new builder as the param
New().
Where("time", "<", "2018-11-02T09:35:25Z").
Or("tag", "=", "t"),
).
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' AND ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
Where("time", ">", "2018-11-01T06:33:57.503Z").
OrBrackets(
// Passing a new builder as the param
New().
Where("time", "<", "2018-11-02T09:35:25Z").
Or("tag", "=", "t"),
).
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" WHERE "time" > '2018-11-01T06:33:57.503Z' OR ("time" < '2018-11-02T09:35:25Z' OR "tag" = 't')
builder := New()
duration := NewDuration()
query := builder.
Select("temperature", "humidity").
From("measurement").
GroupByTime(duration.Minute(10)).
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" GROUP BY time(10m)
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
GroupByTag("sensorId").
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" GROUP BY sensorId
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
Desc().
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" ORDER BY time DESC
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
Limit(10).
Offset(5).
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" LIMIT 10 OFFSET 5
builder := New()
// some code...
builder = builder.Clean()
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
Limit(100).
Offset(100).
Asc().
GetQueryStruct()
/*
type CurrentQuery struct {
Measurement string
Where Tag
And []Tag
Or []Tag
WhereBrackets QueryBuilder
AndBrackets []QueryBuilder
OrBrackets []QueryBuilder
Fields []string
GroupBy string
Limit uint
Offset uint
Order string
IsLimitSet bool
IsOffsetSet bool
}
*/
builder := New()
query := builder.
Select("temperature", "humidity").
From("measurement").
GroupBy("10m").
Build()
Output:
SELECT "temperature","humidity" FROM "measurement" GROUP BY time(10m)
© Ben Hu (benjamin658), 2018-NOW
Released under the MIT License
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.