Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
gcp-metadata
Advanced tools
The gcp-metadata npm package is a library that allows users to query Google Cloud Platform's (GCP) metadata service for information about the currently running instance and project. This can be useful for applications that need to understand their environment within GCP, such as retrieving instance attributes or project details.
Instance Metadata
Retrieve metadata of the current GCP instance. This includes details like the instance ID, zone, and custom metadata.
const gcpMetadata = require('gcp-metadata');
async function getInstanceMetadata() {
if (await gcpMetadata.isAvailable()) {
const instanceMetadata = await gcpMetadata.instance();
console.log(instanceMetadata);
}
}
getInstanceMetadata();
Project Metadata
Fetch metadata of the current GCP project. This can include project-wide attributes like project ID and numeric project number.
const gcpMetadata = require('gcp-metadata');
async function getProjectMetadata() {
if (await gcpMetadata.isAvailable()) {
const projectMetadata = await gcpMetadata.project();
console.log(projectMetadata);
}
}
getProjectMetadata();
Check Metadata Server Availability
Determine if the GCP metadata server is available and reachable from the instance.
const gcpMetadata = require('gcp-metadata');
async function checkAvailability() {
const isAvailable = await gcpMetadata.isAvailable();
console.log('Metadata service available:', isAvailable);
}
checkAvailability();
The AWS SDK for JavaScript allows developers to interact with AWS services. It includes a module for querying the AWS EC2 instance metadata service, which is similar to what gcp-metadata does for GCP.
Get the metadata from a Google Cloud Platform environment.
$ npm install --save gcp-metadata
const gcpMetadata = require('gcp-metadata');
const isAvailable = await gcpMetadata.isAvailable();
const data = await gcpMetadata.instance();
console.log(data); // ... All metadata properties
const data = await gcpMetadata.instance('hostname');
console.log(data) // ...Instance hostname
const data = await gcpMetadata.instance({
property: 'tags',
params: { alt: 'text' }
});
console.log(data) // ...Tags as newline-delimited list
await gcpMetadata.instance({
headers: { 'no-trace': '1' }
}); // ...Request is untraced
In some cases number valued properties returned by the Metadata Service may be
too large to be representable as JavaScript numbers. In such cases we return
those values as BigNumber
objects (from the bignumber.js library). Numbers
that fit within the JavaScript number range will be returned as normal number
values.
const id = await gcpMetadata.instance('id');
console.log(id) // ... BigNumber { s: 1, e: 18, c: [ 45200, 31799277581759 ] }
console.log(id.toString()) // ... 4520031799277581759
FAQs
Get the metadata from a Google Cloud Platform environment
The npm package gcp-metadata receives a total of 0 weekly downloads. As such, gcp-metadata popularity was classified as not popular.
We found that gcp-metadata demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.