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

chore: merge to main for release 1.13.0 #1477

Merged
merged 34 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5e5333e
fix: show vex_counters only when vex is enabled (#1440)
StefanFl Apr 24, 2024
bc0afdb
chore(deps): update dependency types-pymysql to v1.1.0.20240425 (#1442)
renovate[bot] Apr 25, 2024
a054686
chore(deps): update dependency mkdocs-material to v9.5.19 (#1441)
renovate[bot] Apr 25, 2024
798fb7a
chore(deps): update actions/checkout action to v4.1.4 (#1443)
renovate[bot] Apr 25, 2024
35cb1b4
fix(deps): update dependency tss-react to v4.9.7 (#1444)
renovate[bot] Apr 25, 2024
2bbbf90
chore(deps): update react monorepo (#1445)
renovate[bot] Apr 25, 2024
d4514d6
chore(deps): update react monorepo to v18.3.0 (#1446)
renovate[bot] Apr 25, 2024
f6cf003
chore(deps): update dependency black to v24.4.2 (#1447)
renovate[bot] Apr 26, 2024
ec5e751
chore(deps): update github/codeql-action action to v3.25.3 (#1448)
renovate[bot] Apr 26, 2024
0956eb8
feat: copy rule description in the observation log comment (#1451)
StefanFl Apr 27, 2024
d9917cf
chore(deps): update react monorepo (#1450)
renovate[bot] Apr 27, 2024
f48cfae
fix: sorting of potential duplicates (#1452)
StefanFl Apr 27, 2024
0c70263
feat: disable user login (#1453)
StefanFl Apr 28, 2024
d9be75a
fix: clip dependencies directly to maximum size (#1455)
StefanFl Apr 29, 2024
baebaf4
fix: read disable user login feature in Login dialog (#1457)
StefanFl Apr 29, 2024
b163490
chore(deps): update dependency mkdocs-material to v9.5.20 (#1456)
renovate[bot] Apr 29, 2024
d50320b
chore(deps): update typescript-eslint monorepo to v7.8.0 (#1458)
renovate[bot] Apr 30, 2024
2aa6bbd
fix(deps): update dependency tss-react to v4.9.10 (#1460)
renovate[bot] May 1, 2024
4ae6a52
chore(deps): update mysql docker tag to v8.4.0 (#1462)
renovate[bot] May 1, 2024
5d04d35
feat: approval of general rules and product rules (#1464)
StefanFl May 1, 2024
f9212db
fix(deps): update dependency drf-spectacular-sidecar to v2024.5.1 (#1…
renovate[bot] May 1, 2024
edbca82
feat: changed ui for product rules with show page (#1466)
StefanFl May 1, 2024
37a7b5d
fix(deps): update material-ui monorepo to v5.15.16 (#1465)
renovate[bot] May 1, 2024
e8fc536
chore: cache the jwks_uri for 5 minutes (#1467)
StefanFl May 1, 2024
b8721f4
chore(deps): update dependency @types/node to v20.12.8 (#1468)
renovate[bot] May 2, 2024
cf49e0c
chore: documentation for rule approval (#1469)
StefanFl May 2, 2024
e5940d7
chore(deps): update dependency vite to v5.2.11 (#1470)
renovate[bot] May 3, 2024
86bfae9
fix(deps): update react-admin monorepo to v4.16.17 (#1471)
renovate[bot] May 3, 2024
d58305f
chore(deps): update dependency mkdocs-material to v9.5.21 (#1472)
renovate[bot] May 3, 2024
c412d67
feat: show authorization groups for users (#1473)
StefanFl May 4, 2024
465d70c
fix: 2 small ui fixes for product rules (#1475)
StefanFl May 5, 2024
2fcf0b0
chore(deps): update dependency coverage to v7.5.1 (#1474)
renovate[bot] May 5, 2024
94fd9e1
chore(deps): lock file maintenance (#1454)
renovate[bot] May 5, 2024
366b916
chore: prepare for release 1.13.0 (#1476)
StefanFl May 5, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build_push_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
-
name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_push_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: 'v${{ github.event.inputs.release }}'
-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Set up Python 3.12
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_vulnerabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
-
name: Run vulnerability scanners for code
uses: MaibornWolff/secobserve_actions_templates/actions/vulnerability_scanner@b681a7b2089d9be0a0d84179b6fdfd9540e77680 # main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate_sboms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: 'v${{ github.event.inputs.release }}'
-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: 3.x
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scan_sca_current.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: 'v1.12.0'
ref: 'v1.13.0'
-
name: Run SCA vulnerability scanners
uses: MaibornWolff/secobserve_actions_templates/actions/vulnerability_scanner@b681a7b2089d9be0a0d84179b6fdfd9540e77680 # main
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

Expand Down Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@8f596b4ae3cb3c588a5c46780b86dd53fef16c52 # v3.25.2
uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion backend/application/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.12.0"
__version__ = "1.13.0"

import pymysql

Expand Down
44 changes: 43 additions & 1 deletion backend/application/access_control/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
from application.core.models import Product_Member


class UserSerializer(ModelSerializer):
class NestedAuthorizationGroupSerializer(ModelSerializer):
class Meta:
model = Authorization_Group
exclude = ["users"]


class UserListSerializer(ModelSerializer):
permissions = SerializerMethodField()
has_password = SerializerMethodField()

Expand Down Expand Up @@ -77,6 +83,42 @@ def get_has_password(self, obj: User) -> bool:
# eliminate false positive, password is not hardcoded


class UserSerializer(UserListSerializer):
authorization_groups = NestedAuthorizationGroupSerializer(many=True)

class Meta:
model = User
fields = [
"id",
"username",
"first_name",
"last_name",
"full_name",
"email",
"is_active",
"is_superuser",
"is_external",
"setting_theme",
"setting_list_size",
"permissions",
"setting_list_properties",
"oidc_groups_hash",
"is_oidc_user",
"date_joined",
"has_password",
"authorization_groups",
]

def to_representation(self, instance: User):
data = super().to_representation(instance)

user = get_current_user()
if user and not user.is_superuser and not user.pk == instance.pk:
data.pop("authorization_groups")

return data


class UserUpdateSerializer(ModelSerializer):
class Meta:
model = User
Expand Down
3 changes: 3 additions & 0 deletions backend/application/access_control/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
AuthorizationGroupUserSerializer,
CreateApiTokenResponseSerializer,
ProductApiTokenSerializer,
UserListSerializer,
UserPasswordSerializer,
UserPasswortRulesSerializer,
UserSerializer,
Expand Down Expand Up @@ -85,6 +86,8 @@ def get_queryset(self):
return get_users()

def get_serializer_class(self):
if self.action == "list":
return UserListSerializer
if self.action in ["create", "update", "partial_update"]:
return UserUpdateSerializer

Expand Down
14 changes: 2 additions & 12 deletions backend/application/access_control/queries/authorization_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

from application.access_control.models import Authorization_Group
from application.commons.services.global_request import get_current_user
from application.core.queries.product_member import (
get_product_authorization_group_members,
)


def get_authorization_group_by_id(pk: int) -> Optional[Authorization_Group]:
Expand All @@ -24,14 +21,7 @@ def get_authorization_groups() -> QuerySet[Authorization_Group]:

authorization_groups = Authorization_Group.objects.all()

if user.is_superuser or not user.is_external:
if user.is_superuser:
return authorization_groups

product_authorization_group_members = get_product_authorization_group_members()

return authorization_groups.filter(
id__in=[
member.authorization_group_id
for member in product_authorization_group_members
]
)
return authorization_groups.filter(users=user)
7 changes: 6 additions & 1 deletion backend/application/access_control/queries/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ def get_users_without_api_tokens() -> QuerySet[User]:

users = User.objects.exclude(username__startswith="-product-")

if user.is_superuser or not user.is_external:
if user.is_superuser:
return users

users = users.filter(is_active=True)

if not user.is_external:
return users

product_members = get_product_members()
Expand Down
20 changes: 13 additions & 7 deletions backend/application/access_control/services/oidc_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import jwt
import requests
from django.core.cache import cache
from django.db import IntegrityError, transaction
from rest_framework.authentication import BaseAuthentication, get_authorization_header
from rest_framework.exceptions import AuthenticationFailed
Expand Down Expand Up @@ -79,13 +80,18 @@ def _validate_jwt(self, token: str) -> Optional[User]:
raise AuthenticationFailed(str(e)) from e

def _get_jwks_uri(self):
response = requests.request(
method="GET",
url=f"{os.environ['OIDC_AUTHORITY']}/.well-known/openid-configuration",
timeout=60,
)
response.raise_for_status()
return response.json()["jwks_uri"]
jwks_uri = cache.get("jwks_uri")
if not jwks_uri:
response = requests.request(
method="GET",
url=f"{os.environ['OIDC_AUTHORITY']}/.well-known/openid-configuration",
timeout=60,
)
response.raise_for_status()
jwks_uri = response.json()["jwks_uri"]
cache.set("jwks_uri", jwks_uri, timeout=5 * 60)

return jwks_uri

def _create_user(self, username: str, payload: dict) -> User:
user = User(username=username, first_name="", last_name="", email="")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Permissions(IntEnum):
Product_Rule_Delete = 1303
Product_Rule_Create = 1304
Product_Rule_Apply = 1305
Product_Rule_Approval = 1306

Branch_View = 1401
Branch_Edit = 1402
Expand Down Expand Up @@ -132,6 +133,7 @@ def get_product_rule_permissions(cls):
Permissions.Product_Rule_Delete,
Permissions.Product_Rule_Create,
Permissions.Product_Rule_Apply,
Permissions.Product_Rule_Approval,
}

@classmethod
Expand Down Expand Up @@ -228,6 +230,7 @@ def get_roles_with_permissions():
Permissions.Product_Rule_Delete,
Permissions.Product_Rule_Create,
Permissions.Product_Rule_Apply,
Permissions.Product_Rule_Approval,
Permissions.Branch_View,
Permissions.Branch_Edit,
Permissions.Branch_Delete,
Expand Down Expand Up @@ -269,6 +272,7 @@ def get_roles_with_permissions():
Permissions.Product_Rule_Delete,
Permissions.Product_Rule_Create,
Permissions.Product_Rule_Apply,
Permissions.Product_Rule_Approval,
Permissions.Branch_View,
Permissions.Branch_Edit,
Permissions.Branch_Delete,
Expand Down
12 changes: 10 additions & 2 deletions backend/application/commons/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,21 @@ def get(self, request):

class StatusSettingsView(APIView):
serializer_class = StatusSettingsSerializer
permission_classes = []

@action(detail=True, methods=["get"], url_name="settings")
def get(self, request):
features = []

settings = Settings.load()
if settings.feature_vex:
features.append("feature_vex")
if settings.feature_disable_user_login:
features.append("feature_disable_user_login")
if request.user.is_authenticated:
if settings.feature_vex:
features.append("feature_vex")
if settings.feature_general_rules_need_approval:
features.append("feature_general_rules_need_approval")

content = {"features": features}
return Response(content)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-04-27 17:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("commons", "0003_migrate_settings_data"),
]

operations = [
migrations.AddField(
model_name="settings",
name="feature_disable_user_login",
field=models.BooleanField(default=False, help_text="Disable user login"),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.11 on 2024-04-30 04:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("commons", "0004_settings_feature_disable_user_login"),
]

operations = [
migrations.AddField(
model_name="settings",
name="feature_general_rules_need_approval",
field=models.BooleanField(
default=False, help_text="General rules need approval"
),
),
]
6 changes: 6 additions & 0 deletions backend/application/commons/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ class Settings(Model):
feature_vex = BooleanField(
default=False, help_text="Generate VEX documents in OpenVEX and CSAF format"
)
feature_disable_user_login = BooleanField(
default=False, help_text="Disable user login"
)
feature_general_rules_need_approval = BooleanField(
default=False, help_text="General rules need approval"
)

def save(self, *args, **kwargs):
"""
Expand Down
Loading