Giter Site home page Giter Site logo

node-git-wrapper's Introduction

git-wrapper

a wrapper around the git executable

Installation

npm install git-wrapper

API

var git = new Git(options);

Constructor. See git(1) for available options.

  • options Object. Examples: { paginate: true } enables pagination. { 'git-dir': '../.git' } specifies a different .git directory.

git.exec(command [[, options], args], callback);

Executes a git command through child_process.execFile (see documentation). See the Git Reference for available commands.

  • command String. Examples: 'init', 'log', 'commit', etc.
  • options Object. The options for a git command. E.g. { f: true } to force a command (equivalent to adding -f on the command line).
  • args Array[String]. The arguments for a git command. E.g. some files for git add.
  • callback Function. callback(err, msg).

Bugs and Issues

If you encounter any bugs or issues, feel free to open an issue at github.

License

Copyright © 2012 Paul Vorbach

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-git-wrapper's People

Contributors

69 avatar adelriosantiago avatar huntr-helper avatar pvorb avatar zeropaper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-git-wrapper's Issues

child_process.exec limits stdout to 200k, throws exception when git command produces more than 200k of output

I'm trying to run some git commands using git-wrapper that generate more than 200k of output. They are hitting the maxBuffer limit of 200k from child_process.exec and throwing an exception (see http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)

I think a good workaround would be to use child_process.spawn instead. I'll send a pull-request over to demonstrate what I mean.

This StackOverflow thread shows an example of the error I'm talking about with child_process.exec:
https://stackoverflow.com/questions/23429499/stdout-buffer-issue-using-node-child-process

Potentional security flaw

git-wrapper should never ever be used with unchecked values. It's currently not safe for productive usage and apparently was never intended for such a case. The way the arguments are converted to command line is insanely stupid:

var cmd = this.binary + ' ' + this.args + ' ' + command + ' ' + options + ' '
+ args

None of these arguments are checked for shell code or escaped in any way.

So try the following:

node -e 'var g=new (require("git-wrapper"))(".");g.args=";echo ABC";g.exec(";echo DEF", [";echo GHI"], function(e,m){console.log(m)})'

To fix this, you never ever should use exec but spawn instead

cwd is impossible to set for every git comand

cwd option is set in the constructor function, so it's impossible to pass this parameter to exec command every time it's needed. In this case I need to create Git instance for every single exec command.

I offer to to transfer this parameter to exec function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.