Name | aionyphe JSON |
Version |
2.0.5
JSON |
| download |
home_page | None |
Summary | Asynchronous Onyphe API and CLI |
upload_time | 2024-10-18 19:53:17 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License Copyright (c) 2022-2024 koromodako 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, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
onyphe
api
cli
asyncio
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# aionyphe
Asynchronous API SDK and command line interface written in Python
for [Onyphe](https://www.onyphe.io). This software is cross-platform and works
on Linux, Mac and Windows.
Using asyncio enables the user to perform concurrent requests without the need
of threading or subprocessing. Be careful not to trigger the rate limiting
protection though.
## Setup
Setup is almost the same for Linux, Darwin and Windows.
```bash
# assuming 'python' is python 3 executable
python -m venv venv
source venv/bin/activate
pip install git+https://github.com/koromodako/aionyphe
# next line is for linux and darwin only
pip install uvloop
```
## Testing
There is no automated testing for now. Manual testing was performed using
Python 3.10.12 on Ubuntu 22.04. Assume all Python versions above 3.10 are supported.
## Documentation
There is no documentation for now but most of the code is documented.
## Coding rules
Code is formatted using [black](https://github.com/psf/black) and
[Pylint](https://pylint.org) is used to ensure most of the code is
[PEP8](https://www.python.org/dev/peps/pep-0008) compliant and error free.
## API Usage
### Direct connection
```python
from json import dumps
from asyncio import run
from getpass import getpass
from aionyphe import OnypheAPIClient, client_session
async def main():
oql = 'category:synscan ip:8.8.8.8'
api_key = getpass("Enter Onyphe API key: ")
async with client_session(api_key) as client:
api_client = OnypheAPIClient(client=client)
async for _, result in api_client.export(oql):
print(dumps(result))
if __name__ == '__main__':
run(main())
```
### Proxy connection
```python
from json import dumps
from asyncio import run
from getpass import getpass
from aionyphe import OnypheAPIClient, OnypheAPIClientProxy, client_session
async def main():
oql = 'category:synscan ip:8.8.8.8'
api_key = getpass("Enter Onyphe API key: ")
proxy = OnypheAPIClientProxy(
scheme='http', host='squid.domain.tld', port=3128
)
async with client_session(api_key) as client:
api_client = OnypheAPIClient(client=client, proxy=proxy)
async for _, result in api_client.export(oql):
print(dumps(result))
if __name__ == '__main__':
run(main())
```
### Get a specific result page
```python
from json import dumps
from asyncio import run
from getpass import getpass
from aionyphe import OnypheAPIClient, client_session
async def main():
oql = 'category:datascan domain:google.com'
api_key = getpass("Enter Onyphe API key: ")
async with client_session(api_key) as client:
api_client = OnypheAPIClient(client=client)
async for _, result in api_client.search(oql, page=2):
print(dumps(result))
if __name__ == '__main__':
run(main())
```
### A helper to iterate over pages
```python
from json import dumps
from asyncio import run
from getpass import getpass
from aionyphe import OnypheAPIClient, client_session, iter_pages
async def main():
oql = 'category:datascan domain:google.com'
api_key = getpass("Enter Onyphe API key: ")
async with client_session(api_key) as client:
api_client = OnypheAPIClient(client=client)
async for _, result in iter_pages(api_client.search, [oql], 2, 4):
print(dumps(result))
if __name__ == '__main__':
run(main())
```
## Command Line Interface
### Usage
This client does not support as much features as the original Onyphe
[client](https://github.com/onyphe/client) written in Perl but it does allow
the user to pipe the output to another tool keeping the JSON-based pipe interface.
```bash
# get usage information
aionyphe -h
# get 'export' command usage
aionyphe export -h
# export data for given oql query
aionyphe export 'category:synscan ip:8.8.8.8'
# get your public ip address
aionyphe myip
# get information about your user account
aionyphe user | jq
# show pages 2 to 4 for search query
aionyphe search --first 2 --last 4 'category:datascan domain:google.com'
```
### Configuration File (optional)
`aionyphe` client can load configuration from a file depending on the operating
system being used.
| OS | Configuration file |
|:-------:|:--------------------------------|
| Linux | `/home/{username}/.aionyphe` |
| Darwin | `/Users/{username}/.aionyphe` |
| Windows | `C:\Users\{username}\.aionyphe` |
This configuration file shall contain a JSON object with optional key/value
pairs taken from this table :
| Key | Value |
|:----------------:|:------|
| `scheme` | "http" or "https" |
| `host` | Onyphe API hostname |
| `port` | Port as an integer in range 0 -> 65535 |
| `version` | Onyphe API version |
| `api_key` | Onyphe API key (warning: plaintext secret stored on disk!) |
| `proxy_scheme` | "http" or "https" |
| `proxy_host` | Proxy hostname |
| `proxy_port` | Proxy port as an integer in range 0 -> 65535 |
| `proxy_username` | Proxy authentication username |
| `proxy_password` | Proxy authentication password (warning: plaintext secret stored on disk!) |
| `total` | Maximal number of seconds for each request made to the API |
| `connect` | Maximal number of seconds for acquiring a connection from pool |
| `sock_read` | Maximal number of seconds for reading a portion of data from a peer |
| `sock_connect` | Maximal number of seconds for connecting to a peer for a new connection |
Note: command line arguments override configuration file values.
Raw data
{
"_id": null,
"home_page": null,
"name": "aionyphe",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "onyphe, api, cli, asyncio",
"author": null,
"author_email": "koromodako <koromodako@gmail.com>",
"download_url": null,
"platform": null,
"description": "# aionyphe\n\nAsynchronous API SDK and command line interface written in Python\nfor [Onyphe](https://www.onyphe.io). This software is cross-platform and works\non Linux, Mac and Windows.\n\nUsing asyncio enables the user to perform concurrent requests without the need\nof threading or subprocessing. Be careful not to trigger the rate limiting\nprotection though.\n\n## Setup\n\nSetup is almost the same for Linux, Darwin and Windows.\n\n```bash\n# assuming 'python' is python 3 executable\npython -m venv venv\nsource venv/bin/activate\npip install git+https://github.com/koromodako/aionyphe\n# next line is for linux and darwin only\npip install uvloop\n```\n\n## Testing\n\nThere is no automated testing for now. Manual testing was performed using\nPython 3.10.12 on Ubuntu 22.04. Assume all Python versions above 3.10 are supported.\n\n## Documentation\n\nThere is no documentation for now but most of the code is documented.\n\n## Coding rules\n\nCode is formatted using [black](https://github.com/psf/black) and\n[Pylint](https://pylint.org) is used to ensure most of the code is\n[PEP8](https://www.python.org/dev/peps/pep-0008) compliant and error free.\n\n## API Usage\n\n### Direct connection\n\n```python\nfrom json import dumps\nfrom asyncio import run\nfrom getpass import getpass\nfrom aionyphe import OnypheAPIClient, client_session\n\nasync def main():\n oql = 'category:synscan ip:8.8.8.8'\n api_key = getpass(\"Enter Onyphe API key: \")\n async with client_session(api_key) as client:\n api_client = OnypheAPIClient(client=client)\n async for _, result in api_client.export(oql):\n print(dumps(result))\n\nif __name__ == '__main__':\n run(main())\n```\n\n### Proxy connection\n\n```python\nfrom json import dumps\nfrom asyncio import run\nfrom getpass import getpass\nfrom aionyphe import OnypheAPIClient, OnypheAPIClientProxy, client_session\n\nasync def main():\n oql = 'category:synscan ip:8.8.8.8'\n api_key = getpass(\"Enter Onyphe API key: \")\n proxy = OnypheAPIClientProxy(\n scheme='http', host='squid.domain.tld', port=3128\n )\n async with client_session(api_key) as client:\n api_client = OnypheAPIClient(client=client, proxy=proxy)\n async for _, result in api_client.export(oql):\n print(dumps(result))\n\nif __name__ == '__main__':\n run(main())\n```\n\n### Get a specific result page\n\n```python\nfrom json import dumps\nfrom asyncio import run\nfrom getpass import getpass\nfrom aionyphe import OnypheAPIClient, client_session\n\nasync def main():\n oql = 'category:datascan domain:google.com'\n api_key = getpass(\"Enter Onyphe API key: \")\n async with client_session(api_key) as client:\n api_client = OnypheAPIClient(client=client)\n async for _, result in api_client.search(oql, page=2):\n print(dumps(result))\n\nif __name__ == '__main__':\n run(main())\n```\n\n### A helper to iterate over pages\n\n```python\nfrom json import dumps\nfrom asyncio import run\nfrom getpass import getpass\nfrom aionyphe import OnypheAPIClient, client_session, iter_pages\n\nasync def main():\n oql = 'category:datascan domain:google.com'\n api_key = getpass(\"Enter Onyphe API key: \")\n async with client_session(api_key) as client:\n api_client = OnypheAPIClient(client=client)\n async for _, result in iter_pages(api_client.search, [oql], 2, 4):\n print(dumps(result))\n\nif __name__ == '__main__':\n run(main())\n```\n\n## Command Line Interface\n\n### Usage\n\nThis client does not support as much features as the original Onyphe\n[client](https://github.com/onyphe/client) written in Perl but it does allow\nthe user to pipe the output to another tool keeping the JSON-based pipe interface.\n\n```bash\n# get usage information\naionyphe -h\n# get 'export' command usage\naionyphe export -h\n# export data for given oql query\naionyphe export 'category:synscan ip:8.8.8.8'\n# get your public ip address\naionyphe myip\n# get information about your user account\naionyphe user | jq\n# show pages 2 to 4 for search query\naionyphe search --first 2 --last 4 'category:datascan domain:google.com'\n```\n\n### Configuration File (optional)\n\n`aionyphe` client can load configuration from a file depending on the operating\nsystem being used.\n\n| OS | Configuration file |\n|:-------:|:--------------------------------|\n| Linux | `/home/{username}/.aionyphe` |\n| Darwin | `/Users/{username}/.aionyphe` |\n| Windows | `C:\\Users\\{username}\\.aionyphe` |\n\nThis configuration file shall contain a JSON object with optional key/value\npairs taken from this table :\n\n| Key | Value |\n|:----------------:|:------|\n| `scheme` | \"http\" or \"https\" |\n| `host` | Onyphe API hostname |\n| `port` | Port as an integer in range 0 -> 65535 |\n| `version` | Onyphe API version |\n| `api_key` | Onyphe API key (warning: plaintext secret stored on disk!) |\n| `proxy_scheme` | \"http\" or \"https\" |\n| `proxy_host` | Proxy hostname |\n| `proxy_port` | Proxy port as an integer in range 0 -> 65535 |\n| `proxy_username` | Proxy authentication username |\n| `proxy_password` | Proxy authentication password (warning: plaintext secret stored on disk!) |\n| `total` | Maximal number of seconds for each request made to the API |\n| `connect` | Maximal number of seconds for acquiring a connection from pool |\n| `sock_read` | Maximal number of seconds for reading a portion of data from a peer |\n| `sock_connect` | Maximal number of seconds for connecting to a peer for a new connection |\n\nNote: command line arguments override configuration file values.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2022-2024 koromodako 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, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Asynchronous Onyphe API and CLI",
"version": "2.0.5",
"project_urls": {
"Bug Tracker": "https://github.com/koromodako/aionyphe/issues",
"Homepage": "https://github.com/koromodako/aionyphe",
"Repository": "https://github.com/koromodako/aionyphe"
},
"split_keywords": [
"onyphe",
" api",
" cli",
" asyncio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a8607bdebc83515ec2de391bb0dfcbea9f68d45e834241771700e1acaeef6320",
"md5": "cf1a0461b9229f4e163dc29318d42604",
"sha256": "7270522fba04f5433b69acd6873344962c80ff9f26d5966a7cf0e62b18111bc8"
},
"downloads": -1,
"filename": "aionyphe-2.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cf1a0461b9229f4e163dc29318d42604",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 15617,
"upload_time": "2024-10-18T19:53:17",
"upload_time_iso_8601": "2024-10-18T19:53:17.418325Z",
"url": "https://files.pythonhosted.org/packages/a8/60/7bdebc83515ec2de391bb0dfcbea9f68d45e834241771700e1acaeef6320/aionyphe-2.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-18 19:53:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "koromodako",
"github_project": "aionyphe",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aionyphe"
}