This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Library for collecting metrics of the attack surface.

Project Description
# Attack Surface Meter

[![Latest Version](](
[![Build Status](](
[![Coverage Status](](

Attack Surface Meter is a Python package for collecting attack surface metrics from a software system. In its current version, Attack Surface Meter is capable of analyzing software systems written in the C programming language with skeletal support for analyzing software systems written in the Java programming language.

The attack surface metrics collected are:

* Proximity to Entry/Exit/Dangerous - The mean of shortest unweighted path length from a function/file to Entry Points/Exit Points/Dangerous Points.
* Risky Walk - The probability that a function/file will be invoked on a random execution path starting at the attack surface.

## Installation

### PyPI

`pip install attacksurfacemeter`

### Source

`python install`

## Usage

### API

The Attack Surface Meter works off of the call graph representation of a software system. A call graph is parsed by the correponding *loader* to generate an internal representation. In this version, the Attack Surface Meter is capable of parsing the call graph generated by one of the following utilities:

* [GNU cflow]( "GNU cflow")
* [GNU gprof]( "GNU gprof")

Extending the Attack Surface Meter to analyze a software system written in a programming language other than C or Java would require defining a new *loader* to parse a call graph generated by a particular language-specific utility.

#### Example

The code snippet that follows depicts using the Attack Surface Meter API to analyze the a C program for which a call graph generated by GNU cflow is available.

import os
from attacksurfacemeter.call_graph import CallGraph
from attacksurfacemeter.loaders.cflow_loader import CflowLoader

loader = CflowLoader(os.path.expanduser('~/cflow.callgraph.txt'))
call_graph = CallGraph.from_loader(loader)

The `call_graph` object is an instance of the `attacksurfacemeter.call_graph.CallGraph` class and supports several methods to collect the proximity and risky metrics for a given function/file. For more information on these methods, please refer to the `` file which has all the methods extensively documented using Python documentation comments.

### Command Line

usage: [-h] [-gr {function,file}] [-c CFLOW]
[--reverse] [-g GPROF] [-p PROCESSES]
[-j JAVACG] [-a [P [P ...]]] [--output OUTPUT]
[--verbose] [--showerrors]

Collect attack surface metrics from the call graph representation of a
software system.

optional arguments:
-h, --help show this help message and exit
-gr {function,file} The granularity at which the call graphs must be
processed at.
-c CFLOW Absolute path of the file containing the textual
representation of the call graph generated by GNU cflow
or of the directory containing the source code of the
software system to be analyzed.
--reverse cflow call graph was generated with the -r option.
-g GPROF Absolute path of the file containing the textual
representation of the call graph generated by GNU gprof
or of a directory containing multiple such text files.
-p PROCESSES Number of processes to spawn when loaded multiple gprof
call graph files. Default is 2.
-j JAVACG Absolute path of the file containing the textual
representation of the call graph generated by java-
-a [P [P ...]] When using java-callgraph for call graph generation of
android apps, specify the fully qualified package name
of the method calls that will be included in the call
graph. This is generally the name of the java package
inside which the app's classes are defined.
--output OUTPUT Absolute path of the file to which the output should be
written to. The format of output is inferred from the
file extension. txt, html, and xml are currently
supported. In cases when the output format cannot be
inferred, txt is used. When an output path is not
specified, standard output is used.
--verbose Output itemized report including metric values
collected for each function/file.
--showerrors Display errors encountered when parsing call graph (if
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
attacksurfacemeter-0.11.0.tar.gz (499.9 kB) Copy SHA256 Checksum SHA256 Source Aug 2, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting