Merge branch 'main' of github.com:misp/pymisp

pull/1307/head
Christian Studer 2024-11-16 12:31:21 +01:00
commit 2f76ae2bf9
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
12 changed files with 555 additions and 689 deletions

View File

@ -48,11 +48,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
@ -61,7 +61,7 @@ jobs:
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |

View File

@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
@ -26,6 +26,11 @@ jobs:
with:
python-version: ${{matrix.python-version}}
- name: Install python 3.13 specific dependencies
if: ${{ matrix.python-version == '3.13' }}
run: |
sudo apt-get install -y build-essential python3-dev libfuzzy-dev
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip poetry
@ -42,4 +47,4 @@ jobs:
poetry run pytest --cov=pymisp tests/test_*.py
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5

27
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,27 @@
on:
release:
types:
- published
name: release
jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pymisp
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Install Poetry
run: python -m pip install --upgrade pip poetry
- name: Build artifacts
run: poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "pymisp/data/misp-objects"]
path = pymisp/data/misp-objects
url = https://github.com/MISP/misp-objects
[submodule "pymisp/tools/pdf_fonts"]
path = pymisp/tools/pdf_fonts
url = https://github.com/MISP/pdf_fonts

1149
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -216,8 +216,8 @@ class PyMISP:
if 'errors' in response:
logger.warning(response['errors'][0])
else:
pymisp_version_tup = tuple(int(x) for x in __version__.split('.'))
recommended_version_tup = tuple(int(x) for x in response['version'].split('.'))
pymisp_version_tup = tuple(int(x) for x in __version__.split('.')[:3])
recommended_version_tup = tuple(int(x) for x in response['version'].split('.')[:3])
if recommended_version_tup < pymisp_version_tup[:3]:
logger.info(f"The version of PyMISP recommended by the MISP instance ({response['version']}) is older than the one you're using now ({__version__}). If you have a problem, please upgrade the MISP instance or use an older PyMISP version.")
elif pymisp_version_tup[:3] < recommended_version_tup:

@ -1 +1 @@
Subproject commit 83271573312aebce971a0cf7ffbd04e784a58de3
Subproject commit dcf0c3febcacc3b6dd8d0d390b7ec59254cd46ba

@ -1 +0,0 @@
Subproject commit 7ff222022e6ad99e11a201f62d57da4bff1337ee

View File

@ -12,6 +12,8 @@ from pathlib import Path
import sys
import os
import requests
if sys.version_info.major >= 3:
from html import escape
else:
@ -410,10 +412,20 @@ def internationalize_font(config=None):
NotoSansCJKtc - Medium.ttf
'''
font_path = Path(sys.modules['pymisp'].__file__).parent / 'tools' / 'pdf_fonts' / 'Noto_TTF'
noto_bold = font_path / "NotoSansCJKtc-Bold.ttf"
noto = font_path / "NotoSansCJKtc-DemiLight.ttf"
if not font_path.is_dir() or not noto_bold.is_file() or not noto.is_file():
font_path.mkdir(parents=True, exist_ok=True)
if not noto_bold.is_file():
bf = requests.get('https://github.com/MISP/pdf_fonts/raw/refs/heads/master/Noto_TTF/NotoSansCJKtc-Bold.ttf')
with open(noto_bold, 'wb') as f:
f.write(bf.content)
if not noto.is_file():
rf = requests.get('https://github.com/MISP/pdf_fonts/raw/refs/heads/master/Noto_TTF/NotoSansCJKtc-DemiLight.ttf')
with open(noto, 'wb') as f:
f.write(rf.content)
if noto_bold.is_file() and noto.is_file():
registerFont(TTFont("Noto", noto))
registerFont(TTFont("Noto-bold", noto_bold))
@ -421,7 +433,7 @@ def internationalize_font(config=None):
FIRST_COL_FONT = 'Noto-bold'
SECOND_COL_FONT = 'Noto'
else:
logger.error(f"Trying to load a custom (internationalization) font, unable to access the file: {noto_bold}")
logger.error(f"Trying to load a custom (internationalization) font, unable to access the file: {noto_bold} / {noto}")
def get_table_styles():

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "pymisp"
version = "2.5.1"
version = "2.5.2.dev2"
description = "Python API for MISP."
authors = ["Raphaël Vinot <raphael.vinot@circl.lu>"]
license = "BSD-2-Clause"
@ -17,11 +17,11 @@ classifiers=[
'Intended Audience :: Science/Research',
'Intended Audience :: Telecommunications Industry',
'Intended Audience :: Information Technology',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Topic :: Security',
'Topic :: Internet'
]
@ -44,11 +44,11 @@ include = [
"Source" = "https://github.com/MISP/PyMISP"
[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
requests = "^2.32.3"
python-dateutil = "^2.9.0.post0"
deprecated = "^1.2.14"
extract_msg = {version = "^0.51", optional = true}
extract_msg = {version = "^0.52", optional = true}
RTFDE = {version = "^0.1.1", optional = true}
oletools = {version = "^0.60.1", optional = true}
python-magic = {version = "^0.4.27", optional = true}
@ -61,7 +61,7 @@ docutils = {version = "^0.21.1", optional = true, python = ">=3.10"}
recommonmark = {version = "^0.7.1", optional = true, python = ">=3.10"}
reportlab = {version = "^4.2.5", optional = true}
pyfaup = {version = "^1.2", optional = true}
publicsuffixlist = {version = "^1.0.2.20241017", optional = true}
publicsuffixlist = {version = "^1.0.2.20241113", optional = true}
urllib3 = {extras = ["brotli"], version = "*", optional = true}
Sphinx = [
{version = "^8", python = ">=3.10", optional = true}
@ -79,18 +79,17 @@ brotli = ['urllib3']
[tool.poetry.group.dev.dependencies]
requests-mock = "^1.12.1"
mypy = "^1.12.0"
mypy = "^1.13.0"
ipython = [
{version = "<8.13.0", python = "<3.9"},
{version = "^8.18.0", python = ">=3.9"},
{version = "^8.18.0", python = "<3.10"},
{version = "^8.19.0", python = ">=3.10"}
]
jupyterlab = "^4.2.5"
jupyterlab = "^4.3.0"
types-requests = "^2.32.0.20241016"
types-python-dateutil = "^2.9.0.20241003"
types-redis = "^4.6.0.20241004"
types-Flask = "^1.1.6"
pytest-cov = "^5.0.0"
pytest-cov = "^6.0.0"
[build-system]
requires = ["poetry_core>=1.1", "setuptools"]

View File

@ -30,7 +30,7 @@
"name": "file",
"sharing_group_id": "0",
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
"template_version": "24",
"template_version": "25",
"uuid": "a"
},
{
@ -50,7 +50,7 @@
"name": "url",
"sharing_group_id": "0",
"template_uuid": "60efb77b-40b5-4c46-871b-ed1ed999fce5",
"template_version": "9",
"template_version": "10",
"uuid": "b"
}
]

View File

@ -30,7 +30,7 @@
"name": "file",
"sharing_group_id": "0",
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
"template_version": "24",
"template_version": "25",
"uuid": "a"
},
{
@ -55,7 +55,7 @@
"name": "file",
"sharing_group_id": "0",
"template_uuid": "688c46fb-5edb-40a3-8273-1af7923e2215",
"template_version": "24",
"template_version": "25",
"uuid": "b"
}
]