-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adding animation to prompts in documentation - Add CONTRIBUTING.md and SECURITY.md
- Loading branch information
1 parent
dbddcab
commit a4615d7
Showing
15 changed files
with
892 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Contributing to the project | ||
|
||
Thank you very much for wanting to contribute to the project! To contribute, you can open an issue or a pull request. If you want to contribute code, I recommend that you read this document to understand how the project is organized and how to contribute. | ||
|
||
## How is the project organized? | ||
|
||
**Directory structure** | ||
|
||
```mermaid | ||
flowchart | ||
. --> .github | ||
. --> docs | ||
. --> netmikro | ||
. --> tests | ||
. --> pyproject.toml | ||
``` | ||
|
||
The project is divided into three main directories: | ||
|
||
- `netmikro`: Contains the source code of the project. | ||
- `tests`: Contains the tests of the project. | ||
- `docs`: Contains the documentation of the project. | ||
|
||
### netmikro | ||
|
||
```mermaid | ||
flowchart | ||
. --> netmikro | ||
netmikro --> modules | ||
netmikro --> utils | ||
netmikro --> __init__.py | ||
netmikro --> exceptions.py | ||
netmikro --> routeros.py | ||
``` | ||
|
||
All project source code is in the `netmikro` directory. Whenever relevant, the documentation for each module, class or function will be done in the code itself, following the [google docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) standard. So, if you change anything in the code, remember to also update the docstrings (if they exist). | ||
|
||
### Tests | ||
|
||
For testing we are using [pytest](https://docs.pytest.org/). Its settings can be found in the [pyproject.toml](pyproject.toml) file in the root of our project. | ||
|
||
Test coverage is being generated automatically with [pytest-cov](https://github.com/pytest-dev/pytest-cov), being displayed when the test task is executed: | ||
|
||
```bash | ||
task test | ||
``` | ||
|
||
Whenever you run `task test`, three tasks are performed: | ||
|
||
- `pre_test`: Runs `task lint` to check if the code is following the project style standard. | ||
- `test`: Runs the tests. | ||
- `post_test`: Generates the coverage report. | ||
|
||
Each of these tasks are explained in detail in the [Tasks](#tasks) section. | ||
|
||
### Documentation | ||
|
||
The project's documentation is generated with [MkDocs](https://www.mkdocs.org/), with the theme [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) and hosted on [Read the Docs](https://readthedocs.org/). The documentation is written in Markdown and is in the `docs` directory. | ||
|
||
```mermaid | ||
flowchart | ||
. --> docs | ||
docs --> css | ||
docs --> js | ||
docs --> contributing.md | ||
docs --> index.md | ||
. --> mkdocs.yml | ||
``` | ||
|
||
All configuration can be found in the [mkdocs.yml](https://github.com/henriquesebastiao/netmikro/blob/main/mkdocs.yml) file in the root of the repository. | ||
|
||
### Tools | ||
|
||
This project basically uses two tools as a basis for everything with control: | ||
|
||
- [Poetry](https://python-poetry.org/): For environment management and library installation; | ||
- [Taskipy](https://github.com/illBeRoy/taskipy): For automation of routine tasks. How to run tests, linters, etc. | ||
|
||
Ensure you have Poetry installed and properly configured on your machine. | ||
|
||
### Tasks | ||
|
||
Listed here are the project's task settings, which you can use to perform common tasks. How to run tests, linters, etc. | ||
|
||
To run a task, use the following command: | ||
|
||
```bash | ||
task <nome_da_task> | ||
``` | ||
|
||
```toml | ||
[tool.taskipy.tasks] | ||
ruff = "ruff check ." | ||
blue = "blue --check . --diff" | ||
isort = "isort --check --diff ." | ||
mypy = "mypy -p netmikro" | ||
radon = "radon cc ./netmikro -a -na" | ||
bandit = "bandit -r ./netmikro" | ||
pydocstyle = "pydocstyle ./netmikro --count --convention=google --add-ignore=D100,D104,D105,D107" | ||
lint = "task ruff && task blue && task isort" | ||
format = 'blue . && isort .' | ||
docs = "mkdocs serve" | ||
quality = "task mypy && task radon && task pydocstyle" | ||
badge = "coverage-badge -o docs/assets/coverage.svg -f" | ||
pre_test = "task lint" | ||
test = "pytest -s -x --cov=netmikro -vv" | ||
post_test = "coverage html" | ||
export-requirements = "rm requirements.txt && poetry export -f requirements.txt --output requirements.txt --without-hashes" | ||
export-requirements-doc = "poetry export -f requirements.txt --output docs/requirements.txt --without-hashes --only doc" | ||
ready = "task lint && task quality && task bandit && pytest -s -x --cov=netmikro -vv && coverage html && task export-requirements && task export-requirements-doc && task badge" | ||
``` | ||
|
||
#### .github | ||
|
||
```mermaid | ||
flowchart LR | ||
. --> .github | ||
.github --> workflows | ||
workflows --> ci.yml | ||
``` | ||
|
||
The `.github` directory contains the GitHub Actions configuration files. The `ci.yml` file contains the project's CI/CD settings. With it, whenever a commit is made to the `main` branch, GitHub Actions will run tests and linters checking if everything is OK. | ||
|
||
### A recommendation | ||
|
||
To make commits easier to read, it is recommended to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) commit message pattern of semantic commits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Security Policy for Netmikro | ||
|
||
## Overview | ||
|
||
Netmikro is a Python API designed for managing Mikrotik routers. This policy outlines the security measures and | ||
procedures to ensure the safe usage and development of the project. The goal is to protect the Netmikro community and | ||
users from potential threats. | ||
|
||
## RouterOS version support | ||
|
||
| Version | Supported | | ||
|---------|------------| | ||
| 7.14.3 | ✅ | | ||
| Others | Not tested | | ||
|
||
## Reporting Vulnerabilities | ||
|
||
If you discover a vulnerability in Netmikro, please report it immediately by sending an email to [[email protected]](mailto:henriquesebastiao.com). Include the following details: | ||
|
||
- Description of the vulnerability | ||
- Steps to reproduce the issue | ||
- Potential impact | ||
- Suggested mitigation or fix | ||
|
||
I (the maintainer, [@henriquesebastiao](https://twitter.com/hick_hs)) will fully review it and get back to you. | ||
|
||
## Security Best Practices | ||
|
||
When using Netmikro, follow these best practices to safeguard your environment: | ||
|
||
1. **Network Security**: Ensure that routers managed by Netmikro are on a secure network and protected by a firewall. | ||
2. **Updates and Patching**: Keep Netmikro and dependent libraries up to date to receive the latest security fixes. | ||
3. **Logging and Monitoring**: Enable logging to detect suspicious activities and monitor for any unauthorized access. | ||
|
||
## Development Guidelines | ||
|
||
1. **Code Review**: All code changes must go through a thorough review process. | ||
2. **Dependency Management**: Regularly audit dependencies for known vulnerabilities. | ||
3. **Static Code Analysis**: Use static analysis tools to detect security issues during development. | ||
4. **Testing**: Develop comprehensive tests, including unit and integration tests, to identify potential security issues early. | ||
5. **Documentation**: Document any security-related features or configuration to assist users in maintaining secure deployments. | ||
|
||
## Future Enhancements | ||
|
||
We are continuously improving Netmikro's security. Users and contributors are encouraged to provide feedback and suggestions for enhancing the security of the project. | ||
|
||
## Contact | ||
|
||
For security issues or inquiries, please reach out to [[email protected]](mailto:henriquesebastiao.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:::modules.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:::modules.ip |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:::modules.system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# Contributing to the project | ||
|
||
Thank you very much for wanting to contribute to the project! To contribute, you can open an issue or a pull request. If you want to contribute code, I recommend that you read this document to understand how the project is organized and how to contribute. | ||
|
||
## How is the project organized? | ||
|
||
**Directory structure** | ||
|
||
```mermaid | ||
flowchart | ||
. --> .github | ||
. --> docs | ||
. --> netmikro | ||
. --> tests | ||
. --> pyproject.toml | ||
``` | ||
|
||
The project is divided into three main directories: | ||
|
||
- `netmikro`: Contains the source code of the project. | ||
- `tests`: Contains the tests of the project. | ||
- `docs`: Contains the documentation of the project. | ||
|
||
### netmikro | ||
|
||
```mermaid | ||
flowchart | ||
. --> netmikro | ||
netmikro --> modules | ||
netmikro --> utils | ||
netmikro --> __init__.py | ||
netmikro --> exceptions.py | ||
netmikro --> routeros.py | ||
``` | ||
|
||
All project source code is in the `netmikro` directory. Whenever relevant, the documentation for each module, class or function will be done in the code itself, following the [google docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) standard. So, if you change anything in the code, remember to also update the docstrings (if they exist). | ||
|
||
### Tests | ||
|
||
For testing we are using [pytest](https://docs.pytest.org/). Its settings can be found in the [pyproject.toml](pyproject.toml) file in the root of our project. | ||
|
||
Test coverage is being generated automatically with [pytest-cov](https://github.com/pytest-dev/pytest-cov), being displayed when the test task is executed: | ||
|
||
<div class="termy"> | ||
|
||
```console | ||
$ task test | ||
``` | ||
|
||
</div> | ||
|
||
Whenever you run `task test`, three tasks are performed: | ||
|
||
- `pre_test`: Runs `task lint` to check if the code is following the project style standard. | ||
- `test`: Runs the tests. | ||
- `post_test`: Generates the coverage report. | ||
|
||
Each of these tasks are explained in detail in the [Tasks](#tasks) section. | ||
|
||
### Documentation | ||
|
||
The project's documentation is generated with [MkDocs](https://www.mkdocs.org/), with the theme [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) and hosted on [Read the Docs](https://readthedocs.org/). The documentation is written in Markdown and is in the `docs` directory. | ||
|
||
```mermaid | ||
flowchart | ||
. --> docs | ||
docs --> css | ||
docs --> js | ||
docs --> contributing.md | ||
docs --> index.md | ||
. --> mkdocs.yml | ||
``` | ||
|
||
All configuration can be found in the [mkdocs.yml](https://github.com/henriquesebastiao/netmikro/blob/main/mkdocs.yml) file in the root of the repository. | ||
|
||
### Tools | ||
|
||
This project basically uses two tools as a basis for everything with control: | ||
|
||
- [Poetry](https://python-poetry.org/): For environment management and library installation; | ||
- [Taskipy](https://github.com/illBeRoy/taskipy): For automation of routine tasks. How to run tests, linters, etc. | ||
|
||
So, make sure you have poetry installed for this contribution: | ||
|
||
<div class="termy"> | ||
|
||
```console | ||
$ pipx install poetry | ||
``` | ||
|
||
</div> | ||
|
||
## Steps to perform specific tasks | ||
|
||
Listed here are commands that you can use to perform common tasks. How to clone the repository, how to install the dependencies, run the tests, etc... | ||
|
||
### How to clone the repository | ||
|
||
<div class="termy"> | ||
|
||
```console | ||
$ git clone https://github.com/henriquesebastiao/netmikro.git | ||
``` | ||
|
||
</div> | ||
|
||
## How to install dependencies | ||
|
||
<div class="termy"> | ||
|
||
```console | ||
$ poetry install | ||
``` | ||
|
||
</div> | ||
|
||
### Tasks | ||
|
||
Listed here are the project's task settings, which you can use to perform common tasks. How to run tests, linters, etc. | ||
|
||
To run a task, use the following command: | ||
|
||
```bash | ||
task <nome_da_task> | ||
``` | ||
|
||
```toml | ||
[tool.taskipy.tasks] | ||
ruff = "ruff check ." | ||
blue = "blue --check . --diff" | ||
isort = "isort --check --diff ." | ||
mypy = "mypy -p netmikro" | ||
radon = "radon cc ./netmikro -a -na" | ||
bandit = "bandit -r ./netmikro" | ||
pydocstyle = "pydocstyle ./netmikro --count --convention=google --add-ignore=D100,D104,D105,D107" | ||
lint = "task ruff && task blue && task isort" | ||
format = 'blue . && isort .' | ||
docs = "mkdocs serve" | ||
quality = "task mypy && task radon && task pydocstyle" | ||
badge = "coverage-badge -o docs/assets/coverage.svg -f" | ||
pre_test = "task lint" | ||
test = "pytest -s -x --cov=netmikro -vv" | ||
post_test = "coverage html" | ||
export-requirements = "rm requirements.txt && poetry export -f requirements.txt --output requirements.txt --without-hashes" | ||
export-requirements-doc = "poetry export -f requirements.txt --output docs/requirements.txt --without-hashes --only doc" | ||
ready = "task lint && task quality && task bandit && pytest -s -x --cov=netmikro -vv && coverage html && task export-requirements && task export-requirements-doc && task badge" | ||
``` | ||
|
||
#### .github | ||
|
||
```mermaid | ||
flowchart LR | ||
. --> .github | ||
.github --> workflows | ||
workflows --> ci.yml | ||
``` | ||
|
||
The `.github` directory contains the GitHub Actions configuration files. The `ci.yml` file contains the project's CI/CD settings. With it, whenever a commit is made to the `main` branch, GitHub Actions will run tests and linters checking if everything is OK. | ||
|
||
### A recommendation | ||
|
||
To make commits easier to read, it is recommended to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) commit message pattern of semantic commits. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* custom.js | ||
* | ||
* @author Sebastián RamÃrez <[email protected]> | ||
* @license MIT | ||
*/ | ||
|
||
.termynal-comment { | ||
color: #4a968f; | ||
font-style: italic; | ||
display: block; | ||
} | ||
|
||
.termy [data-termynal] { | ||
white-space: pre-wrap; | ||
} | ||
|
||
a.external-link::after { | ||
/* \00A0 is a non-breaking space | ||
to make the mark be on the same line as the link | ||
*/ | ||
content: "\00A0↪"; | ||
} | ||
|
||
/*Usage example: <a href="https://henriquesebastiao.com/" class="external-link" target="_blank">Hick</a>*/ | ||
|
||
/*a.internal-link::after {*/ | ||
/* !* \00A0 is a non-breaking space*/ | ||
/* to make the mark be on the same line as the link*/ | ||
/* *!*/ | ||
/* content: "\00A0↪";*/ | ||
/*}*/ | ||
|
||
.center { | ||
display: block; | ||
margin: 0 auto; | ||
} |
File renamed without changes.
Oops, something went wrong.