Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
octonode is a library for nodejs to access the github v3 api
npm install octonode
var github = require('octonode');
// Then we instanciate a client with or without a token (as show in a later section)
var ghme = client.me();
var ghuser = client.user('pksunkara');
var ghrepo = client.repo('pksunkara/hub');
var ghorg = client.org('flatiron');
var ghgist = client.gist();
var ghteam = client.team(37);
Many of the below use cases use parts of the above code
github.auth.config({
username: 'pksunkara',
password: 'password'
}).login(['user', 'repo', 'gist'], function (err, id, token) {
console.log(id, token);
});
github.auth.config({
username: 'pksunkara',
password: 'password'
}).revoke(id, function (err) {
if (err) throw err;
});
// Web application which authenticates to github
var http = require('http')
, url = require('url')
, qs = require('querystring')
, github = require('octonode');
// Build the authorization config and url
var auth_url = github.auth.config({
id: 'mygithubclientid',
secret: 'mygithubclientsecret'
}).login(['user', 'repo', 'gist']);
// Web server
http.createServer(function (req, res) {
uri = url.parse(req.url);
// Redirect to github login
if (uri.pathname=='/login') {
res.writeHead(301, {'Content-Type': 'text/plain', 'Location': auth_url})
res.end('Redirecting to ' + auth_url);
}
// Callback url from github login
else if (uri.pathname=='/auth') {
github.auth.login(qs.parse(uri.query).code, function (err, token) {
console.log(token);
});
res.writeHead(200, {'Content-Type': 'text/plain'})
res.end('');
} else {
res.writeHead(200, {'Content-Type': 'text/plain'})
res.end('');
}
}).listen(3000);
console.log('Server started on 3000');
var client = github.client();
client.get('/users/pksunkara', function (err, status, body) {
console.log(body); //json object
});
var client = github.client('someaccesstoken');
client.get('/user', function (err, status, body) {
console.log(body); //json object
});
var client = github.client({
username: 'pksunkara',
password: 'password'
});
client.get('/user', function (err, status, body) {
console.log(body); //json object
});
All the callbacks for the following will take first an error argument, then a data argument, like this:
ghme.info(function(err, data) {
console.log("error: " + err);
console.log("data: " + data);
});
Token/Credentials required for the following:
ghme.info(callback); //json
ghme.update({
"name": "monalisa octocat",
"email": "octocat@github.com",
}, callback);
ghme.emails(callback); //array of emails
ghme.emails(['new1@ma.il', 'new2@ma.il'], callback); //array of emails
ghme.emails('new@ma.il', callback); //array of emails
ghme.emails(['new1@ma.il', 'new2@ma.il']);
ghme.emails('new@ma.il');
ghme.followers(callback); //array of github users
ghme.following(callback); //array of github users
ghme.following('marak', callback); //boolean
ghme.follow('marak');
ghme.unfollow('marak');
ghme.keys(callback); //array of keys
ghme.keys(1, callback); //key
ghme.keys({"title":"laptop", "key":"ssh-rsa AAA..."}, callback); //key
ghme.keys(1, {"title":"desktop", "key":"ssh-rsa AAA..."}, callback); //key
ghme.keys(1);
ghme.repos(callback); //array of repos
ghme.repos({
"name": "Hello-World",
"description": "This is your first repo",
}, callback); //repo
ghme.fork('pksunkara/hub', callback); //forked repo
No token required for the following
ghuser.info(callback); //json
ghuser.followers(callback); //array of github users
ghuser.following(callback); //array of github users
ghrepo.info(callback); //json
ghrepo.commits(callback); //array of commits
ghrepo.tags(callback); //array of tags
ghrepo.languages(callback); //array of languages
ghrepo.contributors(callback); //array of github users
ghrepo.branches(callback); //array of branches
ghrepo.issues(callback); //array of issues
ghrepo.readme(callback); //file
ghrepo.readme('v0.1.0', callback); //file
ghrepo.contents('lib/index.js', callback); //path
ghrepo.contents('lib/index.js', 'v0.1.0', callback); //path
ghrepo.archive('tarball', callback); //link to archive
ghrepo.archive('zipball', 'v0.1.0', callback); //link to archive
ghrepo.blob('18293abcd72', callback); //blob
ghrepo.teams(callback); //array of teams
ghorg.info(callback); //json
ghorg.repos(callback); //array of repos
ghorg.repos({
name: 'Hello-world',
description: 'My first world program'
}, callback); //repo
ghorg.teams(callback); //array of teams
ghorg.members(callback); //array of github users
ghorg.member('pksunkara', callback); //boolean
ghgist.list(callback); //array of gists
ghgist.public(callback); //array of gists
ghgist.starred(callback); //array of gists
ghgist.user('pksunkara', callback); //array of gists
ghgist.get(37, callback); //gist
ghgist.create({
description: "the description",
files: { ... }
}), callback); //gist
ghgist.edit(37, {
description: "hello gist"
}, callback); //gist
ghgist.delete(37);
ghgist.star(37);
ghgist.unstar(37);
ghgist.check(37); //boolean
ghgist.comments(37, callback); //array of comments
ghgist.comments(37, {
body: "Just commenting"
}, callback); //comment
ghgist.comment(1, callback); //comment
ghgist.comment(1, {
body: "lol at commenting"
}, callback); //comment
ghgist.comment(1);
ghteam.info(callback); //json
ghteam.members(callback); //array of github users
ghteam.member('pksunkara'); //boolean
npm test
If you like this project, please watch this and follow me.
Here is a list of Contributors
The following method names use underscore as an example. The library contains camel cased method names.
// public orgs for unauthenticated, private and public for authenticated
me.get_organizations(callback);
// public repos for unauthenticated, private and public for authenticated
me.get_watched_repositories(callback);
me.is_watching('repo', callback);
me.start_watching('repo', callback);
me.stop_watching('repo', callback);
me.get_issues(params, callback);
// organization data
var org = octonode.Organization('bulletjs');
org.update(dict_with_update_properties, callback);
org.add_member('user', 'team', callback);
org.remove_member('user', callback);
org.get_public_members(callback);
org.is_public_member('user', callback);
org.make_member_public('user', callback);
org.conceal_member('user', callback);
org.get_team('team', callback);
org.create_team({name:'', repo_names:'', permission:''}, callback);
org.edit_team({name:'', permission:''}, callback);
org.delete_team('name', callback);
org.get_team_members('team', callback);
org.get_team_member('team', 'user', callback);
org.remove_member_from_team('user', 'team', callback);
org.get_repositories(callback);
org.create_repository({name: ''}, callback);
org.get_team_repositories('team', callback);
org.get_team_repository('team', 'name', callback);
org.add_team_repository('team', 'name', callback);
org.remove_team_repository('team', 'name', callback);
var repo = octonode.Repository('pksunkara/octonode');
repo.update({name: ''}, callback);
// collaborator information
repo.get_collaborators(callback);
repo.has_collaborator('name', callback);
repo.add_collaborator('name', callback);
repo.remove_collaborator('name', callback);
// commit data
repo.get_commit('sha-id', callback);
repo.get_all_comments(callback);
repo.get_commit_comments('SHA ID', callback);
repo.comment_on_commit({body: '', commit_id: '', line: '', path: '', position: ''}, callback);
repo.get_single_comment('comment id', callback);
repo.edit_single_comment('comment id', callback);
repo.delete_single_comment('comment id', callback);
// downloads
repo.get_downloads(callback);
repo.get_download(callback);
repo.create_download({name: ''}, 'filepath', callback);
repo.delete_download(callback);
// keys
repo.get_deploy_keys(callback);
repo.get_deploy_key('id', callback);
repo.create_deploy_key({title: '', key: ''}, callback);
repo.edit_deploy_key({title: '', key: ''}, callback);
repo.delete_deploy_key('id', callback);
// watcher data
repo.get_watchers(callback);
// pull requests
repo.get_all_pull_request_comments(callback);
repo.get_pull_request_comment('id', callback);
repo.create_pull_request_comment('id', {body:'', commit_id:'', path:'', position:''}, callback);
repo.reply_to_pull_request_comment('id', 'body', callback);
repo.edit_pull_request_comment('id', 'body', callback);
repo.delete_pull_request_comment('id', callback);
repo.get_issues(params, callback);
repo.get_issue('id', callback);
repo.create_issue({title: ''}, callback);
repo.edit_issue({title: ''}, callback);
repo.get_issue_comments('issue', callback);
repo.get_issue_comment('id', callback);
repo.create_issue_comment('id', 'comment', callback);
repo.edit_issue_comment('id', 'comment', callback);
repo.delete_issue_comment('id', callback);
repo.get_issue_events('id', callback);
repo.get_events(callback);
repo.get_event('id', callback);
repo.get_labels(callback);
repo.get_label('id', callback);
repo.create_label('name', 'color', callback);
repo.edit_label('name', 'color', callback);
repo.delete_label('id', callback);
repo.get_issue_labels('issue', callback);
repo.add_labels_to_issue('issue', ['label1', 'label2'], callback);
repo.remove_label_from_issue('issue', 'labelid', callback);
repo.set_labels_for_issue('issue', ['label1', 'label2'], callback);
repo.remove_all_labels_from_issue('issue', callback);
repo.get_labels_for_milestone_issues('milestone', callback);
repo.get_milestones(callback);
repo.get_milestone('id', callback);
repo.create_milestone('title', callback);
repo.edit_milestone('title', callback);
repo.delete_milestone('id', callback);
// raw git access
repo.create_blob('content', 'encoding', callback);
repo.get_commit('sha-id', callback);
repo.create_commit('message', 'tree', [parents], callback);
repo.get_reference('ref', callback);
repo.get_all_references(callback);
repo.create_reference('ref', 'sha', callback);
repo.update_reference('ref', 'sha', force, callback);
I accept pull requests and guarantee a reply back within a day
MIT/X11
Report here. Guaranteed reply within a day.
Pavan Kumar Sunkara (pavan.sss1991@gmail.com)
FAQs
nodejs wrapper for github v3 api
The npm package octonode receives a total of 10,247 weekly downloads. As such, octonode popularity was classified as popular.
We found that octonode demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.