Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…0urself/from-string-at-enum
  • Loading branch information
y0urself committed Oct 10, 2021
2 parents a4bd399 + d04aea4 commit cc8908f
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
<!-- to check an item, place an "x" in the box like so: "- [x] Tests" -->

- [ ] Tests
- [ ] [CHANGELOG](https://github.com/greenbone/python-gvm/blob/master/CHANGELOG.md) Entry
- [ ] [CHANGELOG](https://github.com/greenbone/python-gvm/blob/main/CHANGELOG.md) Entry
- [ ] Documentation
4 changes: 2 additions & 2 deletions .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build and test Python package

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
linting:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]
paths-ignore:
- '**/*.md'
- '**/*.txt'
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/release-pontos-manually.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release Python package with pontos

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch'
required: true
default: 'main'

jobs:
build-and-release:
env:
GITHUB_USER: ${{ secrets.GREENBONE_BOT }}
GITHUB_MAIL: ${{ secrets.GREENBONE_BOT_MAIL }}
GITHUB_TOKEN: ${{ secrets.GREENBONE_BOT_TOKEN }}
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
name: Build and release with pontos
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
with:
# because we want the git log for conventional commits, we need to fetch deeper!
fetch-depth: 0
persist-credentials: false
branch: ${{ github.event.inputs.branch }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install poetry and dependencies
uses: greenbone/actions/poetry@v1
- name: Tell git who I am
run: |
git config --global user.name "${{ env.GITHUB_USER }}"
git config --global user.email "${{ env.GITHUB_MAIL }}"
git remote set-url origin \
https://${{ env.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Prepare release with pontos
run: |
poetry run pontos-release prepare --calendar -CC
echo "VERSION=$(poetry run pontos-version show)" >> $GITHUB_ENV
- name: Release with pontos
run: |
poetry run pontos-release release -CC
- name: Import key from secrets
run: |
echo -e "${{ env.GPG_KEY }}" >> tmp.file
gpg \
--pinentry-mode loopback \
--passphrase ${{ env.GPG_PASSPHRASE }} \
--import tmp.file
rm tmp.file
- name: Sign with pontos-release sign
run: |
echo "Signing assets for ${{env.VERSION}}"
poetry run pontos-release sign \
--signing-key ${{ env.GPG_FINGERPRINT }} \
--passphrase ${{ env.GPG_PASSPHRASE }} \
--release-version ${{ env.VERSION }}
28 changes: 25 additions & 3 deletions .github/workflows/release-pontos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ jobs:
GITHUB_USER: ${{ secrets.GREENBONE_BOT }}
GITHUB_MAIL: ${{ secrets.GREENBONE_BOT_MAIL }}
GITHUB_TOKEN: ${{ secrets.GREENBONE_BOT_TOKEN }}
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
name: Build and release with pontos
# If the label 'make release' is set. If PR is closed because of an merge
if: contains( github.event.pull_request.labels.*.name, 'make release') && github.event.pull_request.merged == true
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v2
with:
# because we want the git log for conventional commits, we need to fetch deeper!
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v2
Expand All @@ -28,10 +33,27 @@ jobs:
run: |
git config --global user.name "${{ env.GITHUB_USER }}"
git config --global user.email "${{ env.GITHUB_MAIL }}"
git remote set-url origin https://${{ env.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git remote set-url origin \
https://${{ env.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Prepare release with pontos
run: |
poetry run pontos-release prepare --calendar
poetry run pontos-release prepare --calendar -CC
echo "VERSION=$(poetry run pontos-version show)" >> $GITHUB_ENV
- name: Release with pontos
run: |
poetry run pontos-release release
poetry run pontos-release release -CC
- name: Import key from secrets
run: |
echo -e "${{ env.GPG_KEY }}" >> tmp.file
gpg \
--pinentry-mode loopback \
--passphrase ${{ env.GPG_PASSPHRASE }} \
--import tmp.file
rm tmp.file
- name: Sign with pontos-release sign
run: |
echo "Signing assets for ${{env.VERSION}}"
poetry run pontos-release sign \
--signing-key ${{ env.GPG_FINGERPRINT }} \
--passphrase ${{ env.GPG_PASSPHRASE }} \
--release-version ${{ env.VERSION }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

[![GitHub releases](https://img.shields.io/github/release-pre/greenbone/python-gvm.svg)](https://github.com/greenbone/python-gvm/releases)
[![PyPI release](https://img.shields.io/pypi/v/python-gvm.svg)](https://pypi.org/project/python-gvm/)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/greenbone/python-gvm/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/greenbone/python-gvm/?branch=master)
[![code test coverage](https://codecov.io/gh/greenbone/python-gvm/branch/master/graph/badge.svg)](https://codecov.io/gh/greenbone/python-gvm)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/greenbone/python-gvm/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/greenbone/python-gvm/?branch=main)
[![code test coverage](https://codecov.io/gh/greenbone/python-gvm/branch/main/graph/badge.svg)](https://codecov.io/gh/greenbone/python-gvm)
[![Build and test](https://github.com/greenbone/python-gvm/actions/workflows/ci-python.yml/badge.svg)](https://github.com/greenbone/python-gvm/actions/workflows/ci-python.yml)

The Greenbone Vulnerability Management Python API library (**python-gvm**) is a
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if it has been lost.
```sh
git remote add upstream [email protected]:greenbone/python-gvm.git
git fetch upstream
git rebase update/master
git rebase update/main
```

* Get the current version number
Expand Down
30 changes: 30 additions & 0 deletions gvm/protocols/gmpv208/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,32 @@

logger = logging.getLogger(__name__)

_TYPE_FIELDS = [
AggregateStatistic,
AlertCondition,
AlertEvent,
AlertMethod,
AliveTest,
CredentialFormat,
CredentialType,
EntityType,
FeedType,
FilterType,
HostsOrdering,
InfoType,
HelpFormat,
PortRangeType,
PermissionSubjectType,
ReportFormatType,
ScannerType,
SeverityLevel,
SnmpAuthAlgorithm,
SnmpPrivacyAlgorithm,
SortOrder,
TicketStatus,
UserAuthType,
]


class Gmp(
GvmProtocol,
Expand Down Expand Up @@ -195,6 +221,10 @@ def __init__(
*,
transform: Optional[Callable[[str], Any]] = None,
):
self.types = {}
for t in _TYPE_FIELDS:
self.types[t.__name__] = t

super().__init__(connection, transform=transform)

# Is authenticated on gvmd
Expand Down
30 changes: 30 additions & 0 deletions gvm/protocols/gmpv214/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,32 @@

logger = logging.getLogger(__name__)

_TYPE_FIELDS = [
AggregateStatistic,
AlertCondition,
AlertEvent,
AlertMethod,
AliveTest,
CredentialFormat,
CredentialType,
EntityType,
FeedType,
FilterType,
HostsOrdering,
InfoType,
HelpFormat,
PortRangeType,
PermissionSubjectType,
ReportFormatType,
ScannerType,
SeverityLevel,
SnmpAuthAlgorithm,
SnmpPrivacyAlgorithm,
SortOrder,
TicketStatus,
UserAuthType,
]


class Gmp(
GvmProtocol,
Expand Down Expand Up @@ -179,6 +205,10 @@ def __init__(
*,
transform: Optional[Callable[[str], Any]] = None,
):
self.types = {}
for t in _TYPE_FIELDS:
self.types[t.__name__] = t

super().__init__(connection, transform=transform)

# Is authenticated on gvmd
Expand Down
Loading

0 comments on commit cc8908f

Please sign in to comment.