Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Related update #8

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: CD Pipeline
run-name: CD 📦🚀

on:
workflow_dispatch:
workflow_run:
workflows: ["CI Pipeline"]
types: [completed]
branches:
- "main"
paths:
- "src/**"
- "requirements.txt"
- "LICENSE"

jobs:
CD:
Expand All @@ -21,10 +27,6 @@ jobs:
uses: jetpack-io/[email protected]
- name: Install all dependencies 📦
run: devbox run install
- name: 🧹 Linting & Formatting
run: devbox run lint && devbox run format
- name: 🧪 Running Tests
run: devbox run test
- name: 📦 Package
run: devbox run build
- name: 🚀 Publish to PyPI
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ jobs:
- name: 🧹 Linting & Formatting
run: devbox run lint && devbox run format
- name: 🧪 Running Tests
run: devbox run test
run: devbox run test-cov
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- run: echo "🍏 This job's status is ${{ job.status }}."
36 changes: 36 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Security Policy

We take the security of our software seriously. If you believe you've found a security issue in this package, we
encourage you to notify us. We welcome working with you to resolve the issue promptly.

## Supported Versions

We recommend you to use the latest version of the package. We release patches for security vulnerabilities for the
following versions:

| Version | Supported |
|---------|--------------------|
| 0.1.x | :white_check_mark: |

## Reporting a Vulnerability

If you discover a security vulnerability within this package, please contact us by sending an email
to [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.

When reporting a security issue, please provide the following information:

- Your name and affiliation (if any).
- An e-mail address for further discussion.
- Whether you would like to be credited for your discovery.
- If you are not the original discoverer of the vulnerability, please provide contact details of the original
discoverer.
- A description of the technical details of the vulnerabilities. It is very important to let us know how we can
reproduce the vulnerability.
- The versions affected.
- If possible, please provide a proof-of-concept.
- Any configuration information that is important in reproducing the issue.
- The CVSS score for the vulnerability.
- Please do not disclose the vulnerability to the public until we have addressed it.

**Please do not report specifics of security vulnerabilities through public GitHub issues, discussions, or pull
requests.**
3 changes: 3 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"test": [
"pytest src/"
],
"test-cov": [
"pytest src/ --cov=src/ --cov-report=xml"
],
"lint": [
"flake8 src/"
],
Expand Down
4 changes: 4 additions & 0 deletions docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ From outside devbox shell
```bash
devbox run test
```
With Coverage, the coverage report will be generated in the `coverage.xml` file.
```bash
devbox run test-cov
```

## Linting & Formatting

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

long_description = long_description.replace(
"](", "](https://anevis.github.io/yaml-to-markdown/"
)
).replace(".md)", ".html)")

with open("requirements.txt", "r") as req_file:
raw_requirements = req_file.readlines()
Expand Down
10 changes: 10 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sonar.projectKey=anevis_yaml-to-markdown
sonar.organization=anevis

# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=yaml-to-markdown
#sonar.projectVersion=1.0

sonar.sources=src/
sonar.coverage.exclusions=./.pytest_cache/**,**_test.py,**.xml,**.yaml,**.yml
sonar.python.coverage.reportPaths=coverage.xml
9 changes: 5 additions & 4 deletions src/yaml_to_markdown/convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from yaml_to_markdown.convert import convert

_JSON_DATA = '{"key": "value"}'
_OUTPUT_FILE_NAME = "output.md"


def test_convert_with_no_file() -> None:
Expand All @@ -22,11 +23,11 @@ def test_convert_with_json_data(mock_open_file: Mock) -> None:
mock_open_file.return_value.__enter__.return_value = StringIO(_JSON_DATA)

# Execute
convert(output_file="output.md", json_file="test.json")
convert(output_file=_OUTPUT_FILE_NAME, json_file="test.json")

# Assert
mock_open_file.assert_any_call("test.json", "r", encoding="utf-8")
mock_open_file.assert_any_call("output.md", "w", encoding="utf-8")
mock_open_file.assert_any_call(_OUTPUT_FILE_NAME, "w", encoding="utf-8")


@patch("io.open", new_callable=mock_open())
Expand All @@ -36,8 +37,8 @@ def test_convert_with_yaml_data(mock_open_file: Mock) -> None:
mock_open_file.return_value.__enter__.return_value = StringIO(data)

# Execute
convert(output_file="output.md", yaml_file="test.yaml")
convert(output_file=_OUTPUT_FILE_NAME, yaml_file="test.yaml")

# Assert
mock_open_file.assert_any_call("test.yaml", "r", encoding="utf-8")
mock_open_file.assert_any_call("output.md", "w", encoding="utf-8")
mock_open_file.assert_any_call(_OUTPUT_FILE_NAME, "w", encoding="utf-8")