Skip to content

Commit cc0697f

Browse files
[client] Introduce openbas python client
0 parents  commit cc0697f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3555
-0
lines changed

.circleci/config.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
version: 2.1
3+
orbs:
4+
slack: circleci/[email protected]
5+
ms-teams: cloudradar-monitoring/[email protected]
6+
jobs:
7+
ensure_formatting:
8+
docker:
9+
- image: cimg/python:3.12
10+
working_directory: ~/repo
11+
steps:
12+
- checkout
13+
- run:
14+
name: install dependencies
15+
command: pip3 install -r requirements.txt --user
16+
- run:
17+
name: install test-dependencies
18+
command: pip3 install -r test-requirements.txt --user
19+
- run:
20+
name: confirm black version
21+
command: black --version
22+
- run:
23+
name: run isort check
24+
command: isort --check-only .
25+
- run:
26+
name: run black check
27+
command: black --check .
28+
- slack/notify:
29+
branch_pattern: main
30+
event: fail
31+
template: basic_fail_1
32+
- ms-teams/report:
33+
only_on_fail: true
34+
webhook_url: $MS_TEAMS_WEBHOOK_URL
35+
linter:
36+
docker:
37+
- image: alpine/flake8
38+
working_directory: ~/repo
39+
steps:
40+
- checkout
41+
- run:
42+
name: flake8
43+
command: flake8 --ignore=E,W ~/repo
44+
- slack/notify:
45+
branch_pattern: main
46+
event: fail
47+
template: basic_fail_1
48+
- ms-teams/report:
49+
only_on_fail: true
50+
webhook_url: $MS_TEAMS_WEBHOOK_URL
51+
build:
52+
working_directory: ~/openbas-client
53+
docker:
54+
- image: cimg/python:3.12
55+
steps:
56+
- checkout
57+
- run:
58+
name: install dependencies
59+
command: >
60+
pip3 install --user -r requirements.txt -r test-requirements.txt
61+
- run:
62+
name: check version
63+
command: |
64+
package_version="$(
65+
python3 -c 'import pyobas; print(pyobas.__version__)'
66+
)"
67+
[ "${CIRCLE_TAG}" = "${package_version}" ] \
68+
|| printf "Version mismatch: %s is not equal to %s\n" \
69+
"${CIRCLE_TAG}" "${package_version}"
70+
- run:
71+
name: build
72+
command: >
73+
SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct)" python3 -m build
74+
- slack/notify:
75+
branch_pattern: main
76+
event: fail
77+
template: basic_fail_1
78+
- ms-teams/report:
79+
only_on_fail: true
80+
webhook_url: $MS_TEAMS_WEBHOOK_URL
81+
- persist_to_workspace:
82+
root: ~/openbas-client
83+
paths:
84+
- dist
85+
deploy:
86+
working_directory: ~/openbas-client
87+
docker:
88+
- image: cimg/python:3.12
89+
steps:
90+
- checkout
91+
- attach_workspace:
92+
at: ~/openbas-client
93+
- run:
94+
name: install dependencies
95+
command: pip3 install -r requirements.txt --user
96+
- run:
97+
name: install twine
98+
command: pip3 install twine
99+
- run:
100+
name: init .pypirc
101+
command: >
102+
printf "[pypi]\nusername = __token__\npassword = %s\n"
103+
"${PYPI_PASSWORD}" >> ~/.pypirc
104+
- run:
105+
name: upload to pypi
106+
command: twine upload dist/*
107+
- slack/notify:
108+
branch_pattern: main
109+
event: fail
110+
template: basic_fail_1
111+
- ms-teams/report:
112+
only_on_fail: true
113+
webhook_url: $MS_TEAMS_WEBHOOK_URL
114+
notify_rolling:
115+
docker:
116+
- image: "cimg/base:stable"
117+
steps:
118+
- slack/notify:
119+
event: pass
120+
template: basic_success_1
121+
- ms-teams/report:
122+
only_on_fail: false
123+
webhook_url: $MS_TEAMS_WEBHOOK_URL
124+
notify:
125+
docker:
126+
- image: "cimg/base:stable"
127+
steps:
128+
- slack/notify:
129+
event: pass
130+
template: basic_success_1
131+
- ms-teams/report:
132+
only_on_fail: false
133+
webhook_url: $MS_TEAMS_WEBHOOK_URL
134+
135+
workflows:
136+
version: 2
137+
openbas_client_python:
138+
jobs:
139+
- ensure_formatting:
140+
filters:
141+
tags:
142+
only: /.*/
143+
- linter:
144+
filters:
145+
tags:
146+
only: /.*/
147+
- build:
148+
filters:
149+
tags:
150+
only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/
151+
branches:
152+
ignore: /.*/
153+
requires:
154+
- ensure_formatting
155+
- linter
156+
- deploy:
157+
requires:
158+
- build
159+
filters:
160+
tags:
161+
only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/
162+
branches:
163+
ignore: /.*/
164+
- notify_rolling:
165+
requires:
166+
- build
167+
- notify:
168+
requires:
169+
- deploy
170+
filters:
171+
tags:
172+
only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/
173+
branches:
174+
ignore: /.*/

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
ignore = E203, E266, E501, W503, F403, F401
3+
max-line-length = 89
4+
select = B,C,E,F,W,T4,B9
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve OpenBAS
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Please replace every line in curly brackets { like this } with an appropriate answer, and remove this line.
11+
12+
## Description
13+
14+
{ Please provide a clear and concise description of the bug. }
15+
16+
## Environment
17+
18+
1. OS (where OpenCTI server runs): { e.g. Mac OS 10, Windows 10, Ubuntu 16.4, etc. }
19+
2. OpenCTI version: { e.g. OpenCTI 1.0.2 }
20+
3. Other environment details:
21+
22+
## Reproducible Steps
23+
24+
Steps to create the smallest reproducible scenario:
25+
1. { e.g. Run ... }
26+
2. { e.g. Click ... }
27+
3. { e.g. Error ... }
28+
29+
## Expected Output
30+
31+
{ Please describe what you expected to happen. }
32+
33+
## Actual Output
34+
35+
{ Please describe what actually happened. }
36+
37+
## Additional information
38+
39+
{ Any additional information, including logs or screenshots if you have any. }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Feature request
3+
about: Ask for a new feature to be implemented in OpenBAS
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Please replace every line in curly brackets { like this } with appropriate answers, and remove this line.
11+
12+
## Problem to Solve
13+
14+
{ Please describe the problem you would like to solve. }
15+
16+
## Current Workaround
17+
18+
{ Please describe how you currently solve or work around this problem, given OpenBAS's limitation. }
19+
20+
## Proposed Solution
21+
22+
{ Please describe the solution you would like OpenBAS to provide, to solve the problem above. }
23+
24+
## Additional Information
25+
26+
{ Any additional information, including logs or screenshots if you have any. }

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!--
2+
Thank you very much for your pull request to the OpenBAS project! We as a community
3+
driven project depend on support and contributions like this!
4+
5+
Thus already a BIG THANK YOU upfront to you for choosing to help with your PR.
6+
-->
7+
8+
### Proposed changes
9+
10+
*
11+
*
12+
13+
### Related issues
14+
15+
*
16+
*
17+
18+
### Checklist
19+
20+
<!--
21+
Please submit the source code in a way, where you could honestly say `This code is finished`.
22+
If you feel that there are possibilities for improving the code quality, please do so.
23+
By doing this, you are actively helping us to improve the quality of the entire OpenBAS project.
24+
-->
25+
26+
- [ ] I consider the submitted work as finished
27+
- [ ] I tested the code for its functionality
28+
- [ ] I wrote test cases for the relevant uses case
29+
- [ ] I added/update the relevant documentation (either on github or on notion)
30+
- [ ] Where necessary I refactored code to improve the overall quality
31+
32+
<!-- _NOTE: these things are not required to open a PR and can be done afterwards / while the PR draft is open._ -->
33+
<!-- For completed items, change [ ] to [x]. -->
34+
35+
### Further comments
36+
37+
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
# For most projects, this workflow file will not need changing; you simply need
3+
# to commit it to your repository.
4+
#
5+
# You may wish to alter this file to override the set of languages analyzed,
6+
# or to provide custom queries or build logic.
7+
#
8+
# ******** NOTE ********
9+
# We have attempted to detect the languages in your repository. Please check
10+
# the `language` matrix defined below to confirm you have the correct set of
11+
# supported CodeQL languages.
12+
# ******** NOTE ********
13+
14+
name: "CodeQL"
15+
16+
on:
17+
push:
18+
branches:
19+
- master
20+
pull_request:
21+
# The branches below must be a subset of the branches above
22+
branches:
23+
- master
24+
schedule:
25+
- cron: "21 11 * * 0"
26+
27+
jobs:
28+
analyze:
29+
name: Analyze
30+
runs-on: ubuntu-latest
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language:
36+
- python
37+
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
# Initializes the CodeQL tools for scanning.
43+
- name: Initialize CodeQL
44+
uses: github/codeql-action/init@v3
45+
with:
46+
languages: ${{ matrix.language }}
47+
# If you wish to specify custom queries, you can do so here or in a
48+
# config file. By default, queries listed here will override any
49+
# specified in a config file. Prefix the list here with "+" to use
50+
# these queries and those in the config file. queries:
51+
# ./path/to/local/query, your-org/your-repo/queries@main
52+
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or
54+
# Java). If this step fails, then you should remove it and run the build
55+
# manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v3
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following
63+
# three lines and modify them (or add more) to build your code if your
64+
# project uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v3

0 commit comments

Comments
 (0)