Debian Codegraph @

docs/motivation.rst

raw
1 .. Copyright 2017 David Malcolm <[email protected]>
2 Copyright 2017 Red Hat, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 USA
18
19 Motivation
20 ==========
21
22 Motivation: http://lists.fedoraproject.org/pipermail/devel/2012-December/175232.html
23
24 We want to slurp the results from static code analysis into a database,
25 which means coercing all of the results into some common interchange format,
26 codenamed "firehose" (which could also be the name of the database).
27
28 The idea is a common XML format that all tools can emit that:
29
30 * describes a warning
31
32 * gives source-code location of the warning: filename, function,
33 line number.
34
35 * optionally with a `CWE <http://cwe.mitre.org/about/index.html>`_
36 identifier
37
38 * potentially with other IDs and URLs, e.g. the ID "SIG30-C" with URL
39 https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers
40
41 * optionally describes code path to get there (potentially
42 interprocedural across source files), potentially with "state"
43 annotations (e.g. in the case of a reference-counting bug, it's useful
44 to be able to annotate the changes to the refcount).
45
46 together with a simple Python API for working with the format as a
47 collection of Python objects (creating, write to XML, read from XML,
48 modification, etc)
49
50 The data can be round-tripped through both XML and JSON.
51
52 There is a
53 `RELAX-NG schema <https://github.com/fedora-static-analysis/firehose/blob/master/firehose.rng>`_
54 for validating XML files.
55
56 References to source files in the format can include a hash of the source
57 file itself (e.g. SHA-1) so that you can uniquely identify which source file
58 you were talking about.
59
60 This format would be slurped into the DB for the web UI, and can have other
61 things done to it without needing a server:
62 e.g.:
63
64 * convert it to the textual form of a gcc compilation error, so that
65 Emacs etc can parse it and take you to the source
66 * be turned into a simple HTML report locally on your workstation
67
68 Projects using Firehose:
69
70 * `mock-with-analysis <https://github.com/fedora-static-analysis/mock-with-analysis>`_
71 can rebuild a source RPM, capturing the results of 4 different code
72 analysis tools in Firehose format (along with all source files that
73 were mentioned in any report).
74 * The `"firehose" branch
75 <http://git.fedorahosted.org/cgit/gcc-python-plugin.git/log/?h=firehose>`_
76 of
77 `cpychecker <https://gcc-python-plugin.readthedocs.org/en/latest/cpychecker.html>`_
78 can natively emit Firehose XML reports
79 * https://github.com/paultag/storz/blob/master/wrappers/storz-lintian