
OpenStack Security Group에서 제공하는 Python API 보안 테스트 도구
.. image:: http://governance.openstack.org/badges/syntribos.svg :target: http://governance.openstack.org/reference/tags/index.html
.. image:: http://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat :target: http://docs.openstack.org/developer/syntribos/
.. image:: http://img.shields.io/pypi/v/syntribos.svg :target: http://pypi.python.org/pypi/syntribos/
.. image:: http://img.shields.io/pypi/pyversions/syntribos.svg :target: http://pypi.python.org/pypi/syntribos/
.. image:: http://img.shields.io/pypi/wheel/syntribos.svg :target: http://pypi.python.org/pypi/syntribos/
.. image:: http://img.shields.io/irc/%23openstack-security.png :target: http://webchat.freenode.net/?channels=openstack-security
Syntribos는 OpenStack 보안 프로젝트 <https://wiki.openstack.org/wiki/Security>_ 회원들이 유지 관리하는 오픈 소스 자동화 API 보안 테스트 도구입니다.
간단한 구성 파일과 예제 HTTP 요청이 주어지면, syntribos는 모든 API URL, URL 매개변수, HTTP 헤더 및 요청 본문 필드를 주어진 문자열 집합으로 대체할 수 있습니다. Syntribos는 요청 내 각 위치를 자동으로 반복합니다. Syntribos는 SQL 인젝션, LDAP 인젝션, 버퍼 오버플로 등과 같은 일반적인 보안 결함을 자동으로 탐지하는 것을 목표로 합니다. 또한 syntribos는 자동화된 퍼징을 통해 새로운 보안 결함을 식별하는 데 사용될 수 있습니다.
Syntribos는 모든 API를 테스트할 수 있는 기능을 가지고 있지만, OpenStack <https://www.openstack.org/>__ 애플리케이션을 염두에 두고 설계되었습니다.
테스트 목록~~~~~~~~~~~~~
With syntribos, you can initiate automated testing of any API with minimal configuration effort. Syntribos is ideal for testing the OpenStack API as it will help you in automatically downloading a set of templates of some of the bigger OpenStack projects like nova, neutron, keystone, etc.
A short list of tests that can be run using syntribos is given below:
Buffer overflow_ attacks, in the context of a web application,
force an application to handle more data than it can hold in a buffer.
In syntribos, a buffer overflow test is attempted by injecting a large
string into the body of an HTTP request.
Command injection_ attacks are done by injecting arbitrary commands in an
attempt to execute these commands on a remote system. In syntribos, this is
achieved by injecting a set of strings that have been proven as successful
executors of injection attacks.
CORS wildcard_ tests are used to verify if a web server allows cross-domain
resource sharing from any external URL (wild carding of
Access-Control-Allow-Origin header), rather than a white list of URLs.
Integer overflow_ tests in syntribos attempt to inject numeric values that
the remote application may fail to represent within its storage. For example,
injecting a 64 bit number into a 32 bit integer type.
Syntribos attempts LDAP injection_ attacks by injecting LDAP statements
into HTTP requests; if an application fails to properly sanitize the
request content, it may be possible to execute arbitrary commands.
SQL injection_ attacks are one of the most common web application attacks.
If the user input is not properly sanitized, it is fairly easy to
execute SQL queries that may result in an attacker reading sensitive
information or gaining control of the SQL server. In syntribos,
an application is tested for SQL injection vulnerabilities by injecting
SQL strings into the HTTP request.
Some string patterns are not sanitized effectively by the input validator and may cause the application to crash. String validation attacks in syntribos try to exploit this by inputting characters that may cause string validation vulnerabilities. For example, special unicode characters, emojis, etc.
XML external entity_ attacks target the web application's XML parser.
If an XML parser allows processing of external entities referenced in an
XML document then an attacker might be able to cause a denial of service,
or leakage of information, etc. Syntribos tries to inject a few malicious
strings into an XML body while sending requests to an application in an
attempt to obtain an appropriate response.
XSS_ attacks inject malicious JavaScript into a web
application. Syntribos tries to find potential XSS issues by injecting
string containing "script" and other HTML tags into request fields.
ReDoS_ attacks attempt to produce a denial of service by
providing a regular expression that takes a very long time to evaluate.
This can cause the regex engine to backtrack indefinitely, which can
slow down some parsers or even cause a processing halt. The attack
exploits the fact that most regular expression implementations have
an exponential time worst case complexity.
There is a possibility that the JSON parser will reach depth limit and crash, resulting in a successful overflow of the JSON parsers depth limit, leading to a DoS vulnerability. Syntribos tries to check for this, and raises an issue if the parser crashes.
This test gives users the ability to fuzz using user defined fuzz data and
provides an option to look for failure strings provided by the user. The fuzz
data needs to be provided using the config option [user_defined].
Example::
[user_defined] payload=<payload_file> failure_strings=<[list_of_failure_strings] # optional
Other than these built-in tests, you can extend syntribos by writing
your own custom tests. To do this, download the source code and look at
the tests in the syntribos/tests directory. The CORS test may be an easy
one to emulate. In the same way, you can also add different extensions
to the tests. To see how extensions can be written please see the
syntribos/extensions directory.
.. _buffer overflow: https://en.wikipedia.org/wiki/Buffer_overflow .. _Command injection: https://www.owasp.org/index.php/Command_Injection .. _CORS wildcard: https://www.owasp.org/index.php/Test_Cross_Origin_Resource_Sharing_(OTG-CLIENT-007) .. _Integer overflow: https://en.wikipedia.org/wiki/Integer_overflow .. _LDAP injection: https://www.owasp.org/index.php/LDAP_injection .. _SQL injection: https://www.owasp.org/index.php/SQL_Injection .. _XML external entity: https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing .. _XSS: https://www.owasp.org/index.php/Cross-site_Scripting_(XSS) .. _ReDoS: https://en.wikipedia.org/wiki/ReDoS
Details
Documentation_Apache license_Launchpad project_Blueprints_Bugs_Source code_Supported Operating Systems
Syntribos는 주로 Linux 및 Mac 환경에서 개발되었으며, 대부분의 Unix 및 Linux 기반 운영 체제에서 작동합니다. 현재로서는 Windows를 지원하지 않지만, 향후 변경될 수 있습니다.
.. _Documentation: https://docs.openstack.org/developer/syntribos/
.. _Apache license: https://github.com/openstack/syntribos/blob/master/LICENSE
.. _Launchpad project: https://launchpad.net/syntribos
.. _Blueprints: https://blueprints.launchpad.net/syntribos
.. _Bugs: https://bugs.launchpad.net/syntribos
.. _Source code: https://github.com/openstack/syntribos
============
설치
============
Syntribos는 `pypi와 pip를 통해 <https://pypi.python.org/pypi/pip>`__ 직접 설치할 수 있습니다.
::
pip install syntribos
최신 변경 사항을 적용하려면 `소스 <https://www.github.com/openstack/syntribos.git>`__ 에서
`pip <https://pypi.python.org/pypi/pip>`__ 를 통해 syntribos를 설치하세요.
저장소를 복제합니다::
$ git clone https://github.com/openstack/syntribos.git
복제된 저장소 디렉터리로 이동하여 pip로 설치합니다::
$ cd syntribos
$ pip install .
======================================
syntribos 환경 초기화
======================================
syntribos가 설치되면, syntribos 환경을 초기화해야 합니다. 이것은 수동으로 또는 ``init`` 명령어로 수행할 수 있습니다.
::
$ syntribos init
.. Note::
기본적으로 ``syntribos init``는 저희 개발 팀이 유지 관리하는
`원격 저장소 <https://github.com/openstack/syntribos-payloads>`_ 에서 기본 페이로드 파일 세트를 가져옵니다.
이 페이로드 파일은 퍼즈 테스트 실행에 필요합니다.
이 동작을 비활성화하려면 ``--no_downloads`` 플래그와 함께 syntribos를 실행하세요.
페이로드 파일은 언제든지 ``syntribos download --payloads`` 명령을 실행하여 가져올 수도 있습니다.
syntribos가 설치될 사용자 정의 루트를 지정하려면
``--custom_root`` 플래그를 지정하세요. 이렇게 하면 터미널에서 정보 입력을 위한
프롬프트가 생략되며, Jenkins 작업이나 사용자 입력을 받을 수 없는 상황에서 유용합니다.
이미 ``init`` 명령을 실행했지만 새 환경으로 다시 시작하려면 ``--force`` 플래그를
지정하여 기존 파일을 덮어쓸 수 있습니다. ``--custom_root``와 ``--force`` 플래그를 결합하여
사용자 정의 설치 루트의 파일을 덮어쓸 수 있습니다.
참고: 사용자 정의 설치 루트에 syntribos를 설치하는 경우, syntribos를 실행할 때
``--custom_root`` 플래그를 제공해야 합니다.
**예시:**
::
$ syntribos --custom_root /your/custom/path init --force
$ syntribos --custom_root /your/custom/path run
=============
설정
=============
모든 설정 파일에는 ``[syntribos]`` 섹션이 있어야 합니다.
사용 중인 확장 기능과 테스트 대상에 따라 다른 섹션을 추가하세요.
예를 들어, 내장된 ID 확장 기능을 사용하는 경우 ``[user]``
섹션이 필요합니다. ``[logging]`` 및 ``[remote]`` 섹션은 선택 사항입니다.
syntribos 설정 파일의 기본 구조는 다음과 같습니다::
[syntribos]
#
# 테스트할 서비스의 엔드포인트 URL 및 버전.
#
endpoint=http://localhost:5000
# 페이로드 및 템플릿 경로 설정
templates=<템플릿_디렉터리_위치/파일>
payloads=<페이로드_디렉터리_위치>
[user]
#
# AUTH_TOKEN을 얻기 위한 사용자 자격 증명 및 엔드포인트 URL
# 이 섹션은 ID 확장 기능을 사용하는 경우에만 필요합니다.
#
endpoint=
username=<사용자이름>
password=<비밀번호>
[remote]
#
# 선택 사항, 원격 URI 및 cache_dir을 명시적으로 정의하려면
#
templates_uri=<템플릿 세트가 포함된 tar 파일의 URI>
payloads_uri=<페이로드 세트가 포함된 tar 파일의 URI>
cache_dir=<다운로드한 파일을 저장할 로컬 경로>
[logging]
log_dir=<디버그 로그를 저장할 위치>
``[syntribos]`` 섹션에 지정된 엔드포인트 URL은 syntribos가 테스트하는 엔드포인트 URL입니다.
``[user]`` 섹션의 엔드포인트 URL은 AUTH_TOKEN을 얻는 데 사용됩니다.
프로젝트를 테스트하려면 ``[syntribos]`` 아래의 엔드포인트 URL을
API를 가리키도록 업데이트하고 필요한 경우 사용자 자격 증명도 수정하세요.
템플릿 및 페이로드를 원격으로 다운로드하기~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Payload and template files can be downloaded remotely in syntribos.
In the config file under the ``[syntribos]`` section, if the ``templates``
and ``payloads`` options are not set, by default syntribos will
download all the latest payloads and the templates for a few OpenStack
projects.
To specify a URI to download custom templates and payloads
from, use the ``[remotes]`` section in the config file.
Available options under ``[remotes]`` are ``cache_dir``, ``templates_uri``,
``payloads_uri``, and ``enable_cache``. The ``enable_cache`` option is
``True`` by default; set to ``False`` to disable caching of remote
content while syntribos is running. If the ``cache_dir`` set to a path,
syntribos will attempt to use that as a base directory to save downloaded
template and payload files.
The advantage of using these options are that you will be able to get
the latest payloads from the official repository and if you are
using syntribos to test OpenStack projects, then, in most cases you
could directly use the well defined templates available with this option.
This option also helps to easily manage different versions of templates
remotely, without the need to maintain a set of different versions offline.
Testing OpenStack keystone API
A sample config file is given in examples/configs/keystone.conf.
Copy this file to a location of your choice (the default file path for the
configuration file is: ~/.syntribos/syntribos.conf) and update the
necessary fields, such as user credentials, log, template directory, etc.
::
$ vi examples/configs/keystone.conf
[syntribos]
#
# As keystone is being tested in the example, enter your
#
# keystone auth endpoint url.
endpoint=http://localhost:5000
# Set payload and templates path
templates=<location_of_templates_dir/file>
payloads=<location_of_payloads_dir>
[user]
#
# User credentials
#
endpoint=http://localhost:5000
username=<yourusername>
password=<yourpassword>
# Optional, only needed if Keystone V3 API is used
#user_id=<youruserid>
# Optional, api version if required
#version=v2.0
# Optional, for getting scoped tokens
#user_id=<alt_userid>
# If user id is not known
# For V3 API
#domain_name=<name_of_the_domain>
#project_name=<name_of_the_project>
# For Keystone V2 API
#tenant_name=<name_of_the_project>
#[alt_user]
#
# Optional, Used for cross auth tests (-t AUTH)
#
#endpoint=http://localhost:5000
#username=<alt_username>
#password=<alt_password>
# Optional, for getting scoped tokens
#user_id=<alt_userid>
# If user id is not known
# For V3 API
#domain_name=<name_of_the_domain>
#project_name=<name_of_the_project>
# For Keystone V2 API
#tenant_name=<name_of_the_project>
[remote]
#
# Optional, Used to specify URLs of templates and payloads
#
#cache_dir=<a local path to save the downloaded files>
#templates_uri=https://github.com/your_project/templates.tar
#payloads_uri=https://github.com/your_project/payloads.tar
# To disable caching of these remote contents, set the following variable to False
#enable_caching=True
[logging]
#
# Logger options go here
#
log_dir=<location_to_store_log_files>
# Optional, compresses http_request_content,
# if you don't want this, set this option to False.
http_request_compression=True
Below are the set of commands that can be specified while using syntribos:
init
This command sets up the syntribos environment after installation. Running this command creates the necessary folders for templates, payloads, and logs; as well a sample configuration file.
::
$ syntribos init
To learn more about syntribos init, see the installation instructions
here <installation.html>_.
run
This command runs syntribos with the given config options.
::
$ syntribos --config-file keystone.conf -t SQL run
dry_run
This command ensures that the template files given for this run parse successfully and without errors. It then runs a debug test which sends no requests of its own.
::
$ syntribos --config-file keystone.conf dry_run
.. Note:: If any external calls referenced inside the template file do make requests, the parser will still make those requests even for a dry run.
list_tests
This command will list the names of all the tests
that can be executed by the run command with their description.
::
$ syntribos --config-file keystone.conf list_tests
download
This command will download templates and payload files. By default, it will
download a set of OpenStack template files (with the --templates
flag), or a set of payloads (with the --payloads flag) to your
syntribos root directory. However, the behavior of this command can be
configured in the [remote] section of your config file.
::
$ syntribos download --templates
.. Important::
All these commands, except init, will only work if a configuration file
is specified. If a configuration file is present in the default
path ( ~/.syntribos/syntribos.conf ), then you
do not need to explicitly specify a config file and
can run syntribos using the command syntribos run.
By default, syntribos looks in the syntribos home directory (the directory
specified when running the syntribos init command on install) for config
files, payloads, and templates. This can all be overridden through command
line options. For a full list of command line options available, run
syntribos --help from the command line.
To run syntribos against all the available tests, specify the
command syntribos, with the configuration file (if needed), without
specifying any test type.
::
$ syntribos --config-file keystone.conf run
Fuzzy-matching test names
It is possible to limit syntribos to run a specific test type using
the ``-t`` flag.
::
$ syntribos --config-file keystone.conf -t SQL run
This will match all tests that contain ``SQL`` in their name. For example:
``SQL_INJECTION_HEADERS``, ``SQL_INJECTION_BODY``, etc.
Specifying a custom root directory
If you set up the syntribos environment with a custom root (i.e. with
syntribos --custom_root init), you can point to it with the
--custom_root configuration option. Syntribos will look for a
syntribos.conf file inside this directory, and will read further
configuration information from there.
There are two types of logs generated by syntribos:
#. The results log is a collection of issues generated at the end of a syntribos run to represent results. #. The debug log contains debugging information captured during a particular run. Debug logs may include exception messages, warnings, raw but sanitized request/response data, and a few more details. A modified version of Python logger is used for collecting debug logs in syntribos.
Results Log
The results log is displayed at the end of every syntribos run, it can be
written to a file by using the ``-o`` flag on the command line.
The results log includes failures and errors. The ``"failures"`` key represents
tests that have failed, indicating a possible security vulnerability. The
``"errors"`` key gives us information on any unhandled exceptions, such as
connection errors, encountered on that run.
Example failure object:
::
{
"defect_type": "xss_strings",
"description": "The string(s): '[\"<STYLE>@import'http://xss.rocks/xss.css';</STYLE>\"]',
known to be commonly returned after a successful XSS attack, have been found in the
response. This could indicate a vulnerability to XSS attacks.",
"failure_id": 33,
"instances": [
{
"confidence": "LOW",
"param": {
"location": "data",
"method": "POST",
"type": null,
"variables": [
"type",
"details/name",
]
},
"severity": "LOW",
"signals": {
"diff_signals": [
"LENGTH_DIFF_OVER"
],
"init_signals": [
"HTTP_CONTENT_TYPE_JSON",
"HTTP_STATUS_CODE_2XX_201"
],
"test_signals": [
"FAILURE_KEYS_PRESENT",
"HTTP_CONTENT_TYPE_JSON",
"HTTP_STATUS_CODE_2XX_201",
]
},
"strings": [
"<STYLE>@import'http://xss.rocks/xss.css';</STYLE>"
]
}
],
"url": "127.0.0.1/test"
}
Error form:
::
ERROR:
{
"error": "Traceback (most recent call last):\n File \"/Users/test/syntribos/tests/fuzz/base_fuzz.py\",
line 58, in tearDownClass\n super(BaseFuzzTestCase, cls).tearDownClass()\n
File \"/Users/test/syntribos/tests/base.py\", line 166, in tearDownClass\n
raise sig.data[\"exception\"]\nReadTimeout: HTTPConnectionPool(host='127.0.0.1', port=8080):
Read timed out. (read timeout=10)\n",
"test": "tearDownClass (syntribos.tests.fuzz.sql.image_data_image_data_get.template_SQL_INJECTION_HEADERS_sql-injection.txt_str21_model1)"
}
Debug Logs
~~~~~~~~~~
Debug logs include details about HTTP requests, HTTP responses, and other
debugging information such as errors and warnings across the project. The
path where debug logs are saved by default is ``.syntribos/logs/``.
Debug logs are arranged in directories based on the timestamp in these
directories and files are named according to the templates.
For example:
::
$ ls .syntribos/logs/
2016-09-15_11:06:37.198412 2016-09-16_10:11:37.834892 2016-09-16_13:31:36.362584
2016-09-15_11:34:33.271606 2016-09-16_10:38:55.820827 2016-09-16_13:36:43.151048
2016-09-15_11:41:53.859970 2016-09-16_10:39:50.501820 2016-09-16_13:40:23.203920
::
$ ls .syntribos/logs/2016-09-16_13:31:36.362584
API_Versions::list_versions_template.log
API_Versions::show_api_details_template.log
availability_zones::get_availability_zone_detail_template.log
availability_zones::get_availability_zone_template.log
cells::delete_os_cells_template.log
cells::get_os_cells_capacities_template.log
cells::get_os_cells_data_template.log
Each log file includes some essential debugging information such as the string
representation of the request object, signals, and checks used for tests, etc.
Example request::
------------
REQUEST SENT
------------
request method.......: PUT
request url..........: http://127.0.0.1/api
request params.......:
request headers size.: 7
request headers......: {'Content-Length': '0', 'Accept-Encoding': 'gzip, deflate',
'Accept': 'application/json',
'X-Auth-Token': <uuid>, 'Connection': 'keep-alive',
'User-Agent': 'python-requests/2.11.1', 'content-type': 'application/xml'}
request body size....: 0
request body.........: None
Example response::
-----------------
RESPONSE RECEIVED
-----------------
response status..: <Response [415]>
response headers.: {'Content-Length': '70',
'X-Compute-Request-Id': <random id>,
'Vary': 'OpenStack-API-Version, X-OpenStack-Nova-API-Version',
'Openstack-Api-Version': 'compute 2.1', 'Connection': 'close',
'X-Openstack-Nova-Api-Version': '2.1', 'Date': 'Fri, 16 Sep 2016 14:15:27 GMT',
'Content-Type': 'application/json; charset=UTF-8'}
response time....: 0.036277
response size....: 70
response body....: {"badMediaType": {"message": "Unsupported Content-Type", "code": 415}}
-------------------------------------------------------------------------------
[2590] : XSS_BODY
(<syntribos.clients.http.client.SynHTTPClient object at 0x102c65f10>, 'PUT',
'http://127.0.0.1/api')
{'headers': {'Accept': 'application/json', 'X-Auth-Token': <uuid> },
'params': {}, 'sanitize': False, 'data': '', 'requestslib_kwargs': {'timeout': 10}}
Starting new HTTP connection (1): 127.0.0.1
"PUT http://127.0.0.1/api HTTP/1.1" 501 93
Example signals captured::
Signals: ['HTTP_STATUS_CODE_4XX_400', 'HTTP_CONTENT_TYPE_JSON']
Checks used: ['HTTP_STATUS_CODE', 'HTTP_CONTENT_TYPE']
Debug logs are sanitized to prevent storing secrets to log files.
Passwords and other sensitive information are marked with asterisks using a
slightly modified version of `oslo_utils.strutils.mask_password <https://docs.openstack.org/developer/oslo.utils/api/strutils.html#oslo_utils.strutils.mask_password>`__.
Debug logs also include string compression, wherein long fuzz strings are
compressed before being written to the logs. The threshold to start data
compression is set to 512 characters. Although it is not recommended to turn
off compression, it is possible by setting the variable
``"http_request_compression"``, under the logging section in the config file,
to ``False``.
=============================
Anatomy of a request template
=============================
This section describes how to write templates and how to run specific tests.
Templates are input files which have raw HTTP requests and may be
supplemented with variable data using extensions.
In general, a request template is a marked-up raw HTTP request. It's possible
for you to test your application by using raw HTTP requests as your request
templates, but syntribos allows you to mark-up your request templates for
further functionality.
A request template looks something like this:
::
POST /users/{user1} HTTP/1.1
Content-Type: application/json
X-Auth-Token: CALL_EXTERNAL|syntribos.extensions.vAPI.client:get_token:[]|
{"newpassword": "qwerty123"}
For fuzz tests, syntribos will automatically detect URL parameters, headers,
and body content as fields to fuzz. It will not automatically detect URL path
elements as fuzz fields, but they can be specified with curly braces ``{}``.
Note: The name of a template file must end with the extension ``.template``
Otherwise, syntribos will skip the file and will not attempt to parse any files
that do not adhere to this naming scheme.
Using external functions in templates
Extensions can be used to supplement syntribos template files with variable data, or data retrieved from external sources.
Extensions are found in syntribos/extensions/.
Calls to extensions are made in the form below:
::
CALL_EXTERNAL|{extension dot path}:{function name}:[arguments]
One example packaged with syntribos enables the tester to obtain an AUTH
token from keystone. The code is located in identity/client.py.
To use this extension, you can add the following to your template file:
::
X-Auth-Token: CALL_EXTERNAL|syntribos.extensions.identity.client:get_token_v3:["user"]|
The "user" string indicates the data from the configuration file we
added in examples/configs/keystone.conf.
Another example is found in random_data/client.py. This returns a
UUID when random, but unique data is needed. The UUID can be used in place of
usernames when fuzzing a create user call.
::
"username": "CALL_EXTERNAL|syntribos.extensions.random_data.client:get_uuid:[]|"
The extension function can return one value, or be used as a generator if you want it to change for each test.
Syntribos comes with a slew of utility functions/extensions, these functions can be used to dynamically inject data into templates.
.. list-table:: Utility Functions :widths: 15 35 40 :header-rows: 1
All these utility functions can be called using the following syntax:
::
CALL_EXTERNAL|common_utils.client.{method_name}:{comma separated parameters in square brackets}
For example:
::
"encoded_url": "CALL_EXTERNAL|common_utils.client:url_encode:['http://localhost:5000']|
Other functions that return random values can be seen below:
.. list-table:: Random Functions :widths: 15 35 40 :header-rows: 1
These can be called using:
::
CALL_EXTERNAL|random_data.client.{method_name}:{comma separated parameters in square brackets}
For example:
::
"address": "CALL_EXTERNAL|random_data.client:random_ip:[]|"
Action Field
While syntribos is designed to test all fields in a request, it can also
ignore specific fields through the use of Action Fields. If you want to
fuzz against a static object ID, use the Action Field indicator as
follows:
::
"ACTION_FIELD:id": "1a16f348-c8d5-42ec-a474-b1cdf78cf40f"
The ID provided will remain static for every test.
Meta Variable File
Syntribos allows for templates to read in variables from a user-specified meta variable file. These files contain JSON objects that define variables to be used in one or more request templates.
The file must be named meta.json, and they take the form:
::
{
"user_password": {
"val": 1234
},
"user_name": {
"type": config,
"val": "user.username"
"fuzz_types": ["ascii"]
},
"user_token": {
"type": "function",
"val": "syntribos.extensions.identity:get_scoped_token_v3",
"args": ["user"],
"fuzz": false
}
}
To reference a meta variable from a request template, reference the variable
name surrounded by | (pipe). An example request template with meta
variables is as follows:
::
POST /user HTTP/1.1
X-Auth-Token: |user_token|
{
"user": {
"username": "|user_name|",
"password": "|user_password|"
}
}
Note: Meta-variable usage in templates should take the form |user_name|, not
user_|name| or |user|_|name|. This is to avoid ambiguous behavior when the
value is fuzzed.
val - All meta variable objects must define a value, which can be of any json DataType. Unlike the other attributes, this attribute is not optional.
type - Defining a type instructs syntribos to interpret the variable in a certain way. Any variables without a type defined will be read in directly from the value. The following types are allowed:
args - A list of function arguments (if any) which can be defined here if the variable is a generator or a function
fuzz - A boolean value that, if set to false, instructs syntribos to ignore this variable for any fuzz tests
fuzz_types - A list of strings which instructs syntribos to only use certain fuzz strings when fuzzing this variable. More than one fuzz type can be defined. The following fuzz types are allowed:
min_length/max_length - An integer that instructs syntribos to only use fuzz strings that meet certain length requirements
Meta variable files inherit based on the directory it's in. That is, if you
have foo/meta.json and foo/bar/meta.json, templates in foo/bar/ will take
their meta variable values from foo/bar/meta.json, but they can also
reference meta variables that are defined only in foo/meta.json. This also
means that templates in foo/baz/ cannot reference variables defined only in
foo/bar/meta.json.
Each directory can have no more than one file named meta.json.
Running a specific test
As mentioned above, some tests included with syntribos by default
are: LDAP injection, SQL injection, integer overflow, command injection,
XML external entity, reflected cross-site scripting,
Cross Origin Resource Sharing (CORS), SSL, Regex Denial of Service,
JSON Parser Depth Limit, and User defined.
In order to run a specific test, use the `-t, --test-types`
option and provide ``syntribos`` with a keyword, or keywords, to match from
the test files located in ``syntribos/tests/``.
For SQL injection tests, see below:
::
$ syntribos --config-file keystone.conf -t SQL run
To run SQL injection tests against the template body only, see below:
::
$ syntribos --config-file keystone.conf -t SQL_INJECTION_BODY run
For all tests against HTTP headers only, see below:
::
$ syntribos --config-file keystone.conf -t HEADERS run
============
Unit testing
============
To execute unit tests automatically, navigate to the ``syntribos`` root
directory and install the test requirements.
::
$ pip install -r test-requirements.txt
Now, run the ``unittest`` as below:
::
$ python -m unittest discover tests/unit -p "test_*.py"
If you have configured tox you could also run the following:
::
$ tox -e py27
$ tox -e py35
This will run all the unit tests and give you a result output
containing the status and coverage details of each test.
=======================
Contributing Guidelines
=======================
Syntribos is an open source project and contributions are always
welcome. If you have any questions, we can be found in the
#openstack-security channel on Freenode IRC.
1. Follow all the `OpenStack Style Guidelines <https://docs.openstack.org/developer/hacking/>`__
(e.g. PEP8, Py3 compatibility)
2. Follow `secure coding guidelines <https://security.openstack.org/#secure-development-guidelines>`__
3. Ensure all classes/functions have appropriate `docstrings <https://www.python.org/dev/peps/pep-0257/>`__
in `RST format <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`__
4. Include appropriate unit tests for all new code(place them in the
``tests/unit`` folder)
5. Test any change you make using tox:
::
pip install tox
tox -e pep8
tox -e py27
tox -e py35
tox -e cover
Anyone wanting to contribute to OpenStack must follow
`the OpenStack development workflow <https://docs.openstack.org/infra/manual/developers.html#development-workflow>`__
Submit all changes through the code review process in Gerrit
described above. All pull requests on Github will be closed/ignored.
File bugs on the `syntribos launchpad site <https://bugs.launchpad.net/syntribos>`__,
and not on Github. All Github issues will be closed/ignored.
Submit blueprints `here <https://blueprints.launchpad.net/syntribos>`__ for all
breaking changes, feature requests, and other unprioritized work.
.. Note:: README.rst is a file that can be generated by running
``python readme.py`` from the ``syntribos/scripts`` directory. When the
README file needs to be updated; modify the corresponding rst file in
``syntribos/doc/source`` and have it generate by running the script.