Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
github.com/evalphobia/google-api-go-wrapper
golang wrapper library of Google APIs Client Library for Go
Depends on the google's each libraries.
Install google-api-go-wrapper and required packages using go get
command:
$ go get github.com/evalphobia/google-api-go-wrapper/...
// create client by given paramter.
client = analytics.New(config.Config{
PrivateKey: `-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----`,
Email: "xxx@xxx.gserviceaccount.com",
})
// create client by json body.
client = analytics.New(config.Config{
CredsJSONBody: `{
"type":"service_account",
"private_key":"-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----",
"client_email":"xxx@xxx.gserviceaccount.com"
}`,
})
// create client by given file path of credential.
client = analytics.New(config.Config{
Filename: "/path/to/pem.json",
})
// use env parameter when above fields are empty.
// $GOOGLE_API_GO_PRIVATEKEY : used as `PrivateKey` field.
// $GOOGLE_API_GO_EMAIL : used as `Email` field.
// $GOOGLE_API_GO_JSON : used as `CredsJSONBody` field.
client = analytics.New(config.Config{})
If no other credentials could be found, Config
will use https://godoc.org/golang.org/x/oauth2/google#FindDefaultCredentials.
Some clients have SetLogger
method.
You can set custom logger and handle error message from Google's API.
These default logger is defined in this library.
DummyLogger is default logger. This do nothing. Just ignore errors.
import (
"github.com/evalphobia/google-api-go-wrapper/log"
)
client.SetLogger(&log.DummyLogger{})
StdLogger prints error messages on stderr.
import (
"github.com/evalphobia/google-api-go-wrapper/log"
)
client.SetLogger(&log.StdLogger{})
Stackdriver Error Reporting Logger sends error messages to Stackdriver Error Reporting.
Install google's library:
$ go get google.golang.org/api/analytics/v3
import (
"github.com/evalphobia/google-api-go-wrapper/analytics"
"github.com/evalphobia/google-api-go-wrapper/config"
)
...
client := analytics.New(config.Config{})
viewID := "00000000"
result, err := cli.GetRealtimeActiveUser(viewID)
if err != nil {
fmt.Printf("[ERROR] %s\n", err.Error())
return
}
fmt.Printf("activeUser=%d\n", result)
Install google's library:
$ go get google.golang.org/api/bigquery/v2
import (
"github.com/evalphobia/google-api-go-wrapper/bigquery"
"github.com/evalphobia/google-api-go-wrapper/config"
)
...
ds, err := bigquery.NewDataset(config.Config{}, projectID, datasetID)
if err != nil {
panic(err)
}
err = ds.CreateTable(tableID, MySchema{})
if err != nil {
panic(err)
}
...
type MySchema struct {
Name string `bigquery:"username"`
CreatedAt time.Time `bigquery:"created_at"`
}
import (
"github.com/evalphobia/google-api-go-wrapper/bigquery"
"github.com/evalphobia/google-api-go-wrapper/config"
)
...
ds, err := bigquery.NewDataset(config.Config{}, projectID, datasetID)
if err != nil {
panic(err)
}
err = ds.InserAll(tableID, &MySchema{
Name: "foo",
CreatedAt: time.Now(),
})
if err != nil {
panic(err)
}
...
type MySchema struct {
Name string `bigquery:"username"`
CreatedAt time.Time `bigquery:"created_at"`
}
Install google's library:
$ go get google.golang.org/api/logging/v2
$ go get google.golang.org/api/monitoring/v3
import (
"github.com/evalphobia/google-api-go-wrapper/config"
"github.com/evalphobia/google-api-go-wrapper/stackdriver/logging"
)
...
logger, err := logging.NewLogger(config.Config{}, projectID)
if err != nil {
panic(err)
}
err = logger.Write(logging.WriteData{
Data: map[string]interface{}{"key": "value"},
LogName: "test_log",
Resource: &logging.Resource{
Type: "global",
},
})
if err != nil {
panic(err)
}
import (
"github.com/evalphobia/google-api-go-wrapper/config"
"github.com/evalphobia/google-api-go-wrapper/stackdriver/monitoring"
)
...
monitor, err := monitoring.NewMonitor(config.Config{}, projectID)
if err != nil {
panic(err)
}
err = monitor.Create(monitoring.Data{
Data: 100,
MetricType: "foo_sales",
MetricKind: monitoring.MetricKindGauge,
Resource: &monitoring.Resource{
Type: "global",
},
})
if err != nil {
panic(err)
}
Install google's library:
$ go get google.golang.org/api/vision/v1
import (
"fmt"
"io/ioutil"
"github.com/evalphobia/google-api-go-wrapper/config"
"github.com/evalphobia/google-api-go-wrapper/vision"
)
...
client, err := vision.New(config.Config{})
if err != nil {
panic(err)
}
img, err := ioutil.ReadFile(file)
if err != nil {
panic(err)
}
faceResult, err := cli.Face(img)
if err != nil {
panic(err)
}
fmt.Printf("FaceDetect=%+v\n", faceResult.FaceResult())
safeResult, err := cli.Safe(img)
if err != nil {
panic(err)
}
fmt.Printf("SafeSearch=%+v\n", safeResult.SafeResult())
textResult, err := cli.Text(img)
if err != nil {
panic(err)
}
fmt.Printf("TextDetect=%+v\n", textResult.TextResult())
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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.