Coder Social home page Coder Social logo

agamotto's Introduction

Agamotto

Agamotto is a helper module to make it easier to test a running system with Python.

Why not use serverspec? I work in a Python shop and want to make it as easy as possible for our devs to be able to easily write their own tests. Making the test suite use the same language they use daily removes a potential friction point.

Installation

pip install agamotto

Usage

import agamotto
import unittest2 as unittest

class TestKnownSecurityIssues(unittest.TestCase):

  def testBashHasCVE_2014_6271Fix(self):
    """Confirm that fix has been installed for CVE-2014-6271 Bash Code
    Injection Vulnerability via Specially Crafted Environment Variables
    """
    self.assertFalse(agamotto.process.stdoutContains("(env x='() { :;}; echo vulnerable'  bash -c \"echo this is a test\") 2>&1",
                     'vulnerable'), 'Bash is vulnerable to CVE-2014-6271')


  def testBashHasCVE_2014_7169Fix(self):
    """Confirm that fix has been installed for CVE-2014-7169 Bash Code
    Injection Vulnerability via Specially Crafted Environment Variables
    """
    self.assertFalse(agamotto.process.stdoutContains("env X='() { (a)=>\' bash -c \"echo echo vuln\"; [[ \"$(cat echo)\" == \"vuln\" ]] && echo \"still vulnerable :(\" 2>&1",
                     'still vulnerable'), 'Bash is vulnerable to CVE-2014-7169')


  def testNoAccountsHaveEmptyPasswords(self):
    """/etc/shadow has : separated fields. Check the password field ($2) and
       make sure no accounts have a blank password.
    """
    self.assertEquals(agamotto.process.execute(
      'sudo awk -F: \'($2 == "") {print}\' /etc/shadow | wc -l').strip(), '0',
      "found accounts with blank password")


  def testRootIsTheOnlyUidZeroAccount(self):
    """/etc/passwd stores the UID in field 3. Make sure only one account entry
    has uid 0.
    """
    self.assertEquals(agamotto.process.execute(
                      'awk -F: \'($3 == "0") {print}\' /etc/passwd').strip(),
                      'root:x:0:0:root:/root:/bin/bash')



if __name__ == '__main__':
  unittest.main()

Then run py.test.

Caveats

We're a CentOS shop. This hasn't even been tested on stock RHEL, let alone Debian or Ubuntu. Pull requests adding that functionality are welcome, of course.

agamotto's People

Contributors

unixorn avatar

Watchers

 avatar  avatar  avatar

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.