
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
gitlab-restapi
Advanced tools
The module allows you to perform the list of methods described in the GitLab service documentation in the section Jobs , Pipelines ( for now)
And you can Add your own method that is not yet implemented by this api
And yes, let's start!
First install Node.js
npm i gitlab-restapi
const GitLab = require("gitlab-restapi");
const gitLab = new GitLab.API(new GitLab.Options({
privateToken: process.env.GIT_TOKEN,
projectId: process.env.GIT_PID,
}));
const jobs = await gitLab.Jobs.jobs(
new GitLab.PaginateParams({
page: 1, per_page: 100, scope: ['success', 'failed']
}));
// find first(last executed) Job by name
const job = jobs.find({name: 'testofclasses'});
console.log(job.status)
GitLab.Options can specify your method for fetching data. For nodes 18+ - this is the own node fetch (by default), for younger versions (unless otherwise specified) - the internal mechanism
new GitLab.Options({
privateToken: process.env.GIT_TOKEN,
projectId: process.env.GIT_PID,
fetchMethod: fetch // axios, fetch, node-fetch, GitLab.Request (tested)
})
const GitLab = require("gitlab-restapi");
const gitLab = new GitLab.API(new GitLab.Options({
privateToken: process.env.GIT_TOKEN,
projectId: process.env.GIT_PID,
fetchMethod: fetch // axios, fetch, node-fetch, GitLab.Request (tested)
}));
console.log(gitLab.Jobs.methods)
// list of registered APIs
console.log(gitLab.getOwnPropertyNames())
Get a single job of a project
const jobs = await gitLab.Jobs.jobs(
new GitLab.PaginateParams({page: 1, per_page: 1, scope: ['success']}));
// const jobs = await gitLab.Jobs.jobs(new GitLab.PaginateParams({})); // page: 1, per_page: 20, all scopes
// const jobs = await gitLab.Jobs.jobs(); // page: 1, per_page: 20, all scopes
console.log('jobs:', jobs.list)
const _job = jobs.find({status: 'success'});
console.log('found:', _job)
const job = await gitLab.Jobs.job(_job.id);
console.log('Get a single job of a project by id:', job)
Erase a single job of a project (remove job artifacts and a job log)
const jobs = await gitLab.Jobs.jobs(new GitLab.PaginateParams({
page: 1,
per_page: 100,
scope: ['failed', 'canceled']
}));
const erasedJobs = new GitLab.Jobs([])
for (let job of jobs.list) {
if (job.artifacts && job.artifacts.length) {
const obj = await gitLab.Jobs.erase(job.id);
if (obj) erasedJobs.push(obj)
}
}
console.log(erasedJobs.list)
const pipelinelatest = await gitLab.Pipelines.latest();
console.log(pipelinelatest)
const pipelines = await gitLab.Pipelines.pipelines(new GitLab.PaginateParams({
page: 1, per_page: 20, status: 'success', source: 'push',}));
console.log(pipelines.list)
Add your own method that is not yet implemented by this api
gitLab.add('MyGroups').addMethods({
groups: new GitLab.Method({method: 'get', class: GitLab.Responses,
url: () => `groups`})
})
console.log(gitLab.MyGroups.methods)
const groups = await gitLab.MyGroups.groups(
new GitLab.PaginateParams({page: 2, per_page: 20}));
console.log(groups.list)
gitLab.add('MyReleases').addMethods({
releases: new GitLab.Method({method: 'get', class: GitLab.Responses,
url: () => `projects/${gitLab.projectId}/releases`})
})
console.log(gitLab.MyReleases.methods)
const releases = await gitLab.MyReleases.releases(new GitLab.PaginateParams({page: 2, per_page: 20}));
console.log(releases.list)
Thanks for your attention - the continuation of the api will come soon
FAQs
Integration with GitLab REST API
We found that gitlab-restapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.