Skip to content

Commit f8643be

Browse files
committed
Merge branch 'dev' of https://github.com/MaibornWolff/SecObserve into stackable
2 parents 0f6f8b5 + c31b9cd commit f8643be

15 files changed

Lines changed: 73 additions & 31 deletions

File tree

backend/application/core/queries/product.py

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.db.models.query import QuerySet
66

77
from application.access_control.services.current_user import get_current_user
8+
from application.commons.models import Settings
89
from application.core.models import (
910
Observation,
1011
Product,
@@ -86,6 +87,12 @@ def _add_annotations(queryset: QuerySet, is_product_group: bool, with_annotation
8687
if not with_annotations:
8788
return queryset
8889

90+
queryset = _add_observation_annotations(queryset, is_product_group)
91+
queryset = _add_license_annotations(queryset, is_product_group)
92+
return queryset
93+
94+
95+
def _add_observation_annotations(queryset: QuerySet, is_product_group: bool) -> QuerySet:
8996
subquery_open_critical = (
9097
_get_product_group_observation_subquery(Severity.SEVERITY_CRITICAL)
9198
if is_product_group
@@ -117,49 +124,58 @@ def _add_annotations(queryset: QuerySet, is_product_group: bool, with_annotation
117124
else _get_product_observation_subquery(Severity.SEVERITY_UNKNOWN)
118125
)
119126

120-
subquery_license_forbidden = (
121-
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_FORBIDDEN)
122-
if is_product_group
123-
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_FORBIDDEN)
124-
)
125-
subquery_license_review_required = (
126-
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_REVIEW_REQUIRED)
127-
if is_product_group
128-
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_REVIEW_REQUIRED)
129-
)
130-
subquery_license_unknown = (
131-
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_UNKNOWN)
132-
if is_product_group
133-
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_UNKNOWN)
134-
)
135-
subquery_license_allowed = (
136-
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_ALLOWED)
137-
if is_product_group
138-
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_ALLOWED)
139-
)
140-
subquery_license_ignored = (
141-
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_IGNORED)
142-
if is_product_group
143-
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_IGNORED)
144-
)
145-
146127
queryset = queryset.annotate(
147128
open_critical_observation_count=Coalesce(subquery_open_critical, 0),
148129
open_high_observation_count=Coalesce(subquery_open_high, 0),
149130
open_medium_observation_count=Coalesce(subquery_open_medium, 0),
150131
open_low_observation_count=Coalesce(subquery_open_low, 0),
151132
open_none_observation_count=Coalesce(subquery_open_none, 0),
152133
open_unknown_observation_count=Coalesce(subquery_open_unknown, 0),
153-
forbidden_licenses_count=Coalesce(subquery_license_forbidden, 0),
154-
review_required_licenses_count=Coalesce(subquery_license_review_required, 0),
155-
unknown_licenses_count=Coalesce(subquery_license_unknown, 0),
156-
allowed_licenses_count=Coalesce(subquery_license_allowed, 0),
157-
ignored_licenses_count=Coalesce(subquery_license_ignored, 0),
158134
)
159135

160136
return queryset
161137

162138

139+
def _add_license_annotations(queryset: QuerySet, is_product_group: bool) -> QuerySet:
140+
settings = Settings.load()
141+
if settings.feature_license_management:
142+
subquery_license_forbidden = (
143+
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_FORBIDDEN)
144+
if is_product_group
145+
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_FORBIDDEN)
146+
)
147+
subquery_license_review_required = (
148+
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_REVIEW_REQUIRED)
149+
if is_product_group
150+
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_REVIEW_REQUIRED)
151+
)
152+
subquery_license_unknown = (
153+
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_UNKNOWN)
154+
if is_product_group
155+
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_UNKNOWN)
156+
)
157+
subquery_license_allowed = (
158+
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_ALLOWED)
159+
if is_product_group
160+
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_ALLOWED)
161+
)
162+
subquery_license_ignored = (
163+
_get_product_group_license_subquery(License_Policy_Evaluation_Result.RESULT_IGNORED)
164+
if is_product_group
165+
else _get_product_license_subquery(License_Policy_Evaluation_Result.RESULT_IGNORED)
166+
)
167+
168+
queryset = queryset.annotate(
169+
forbidden_licenses_count=Coalesce(subquery_license_forbidden, 0),
170+
review_required_licenses_count=Coalesce(subquery_license_review_required, 0),
171+
unknown_licenses_count=Coalesce(subquery_license_unknown, 0),
172+
allowed_licenses_count=Coalesce(subquery_license_allowed, 0),
173+
ignored_licenses_count=Coalesce(subquery_license_ignored, 0),
174+
)
175+
176+
return queryset
177+
178+
163179
def _get_product_observation_subquery(severity: str) -> Subquery:
164180
branch_filter = Q(branch__is_default_branch=True) | (
165181
Q(branch__isnull=True) & Q(product__repository_default_branch__isnull=True)

charts/secobserve/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ A Helm chart to deploy SecObserve, an open-source vulnerability and license mana
113113
| frontend.env[4].value | string | `"https://secobserve.dev/"` | |
114114
| frontend.env[5].name | string | `"OIDC_POST_LOGOUT_REDIRECT_URI"` | |
115115
| frontend.env[5].value | string | `"https://secobserve.dev/"` | |
116+
| frontend.env[5].name | string | `"OIDC_PROMPT"` | |
117+
| frontend.env[5].value | string | null | |
116118
| frontend.image.pullPolicy | string | `"IfNotPresent"` | |
117119
| frontend.image.registry | string | `"docker.io"` | |
118120
| frontend.image.repository | string | `"ghcr.io/secobserve/secobserve-frontend"` | |

charts/secobserve/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ frontend:
2525
value: https://secobserve.dev/
2626
- name: OIDC_POST_LOGOUT_REDIRECT_URI
2727
value: https://secobserve.dev/
28+
- name: OIDC_PROMPT
29+
value: null
2830
resources:
2931
limits:
3032
cpu: 500m

docker-compose-dev-keycloak.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
OIDC_CLIENT_ID: ${SO_OIDC_CLIENT_ID:-secobserve}
2222
OIDC_REDIRECT_URI: ${SO_OIDC_REDIRECT_URI:-http://localhost:3000}
2323
OIDC_POST_LOGOUT_REDIRECT_URI: ${SO_OIDC_POST_LOGOUT_REDIRECT_URI:-http://localhost:3000}
24+
OIDC_PROMPT: ${SO_OIDC_PROMPT:-}
2425

2526
backend:
2627
build:

docker-compose-playwright.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ services:
1818
OIDC_CLIENT_ID: dummy
1919
OIDC_REDIRECT_URI: dummy
2020
OIDC_POST_LOGOUT_REDIRECT_URI: dummy
21+
OIDC_PROMPT: null
22+
2123
networks:
2224
- secobserve
2325

docker-compose-prod-mysql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ services:
5050
OIDC_REDIRECT_URI: ${SO_OIDC_REDIRECT_URI:-http://secobserve.localhost}
5151
OIDC_POST_LOGOUT_REDIRECT_URI: ${SO_OIDC_POST_LOGOUT_REDIRECT_URI:-http://secobserve.localhost}
5252
OIDC_SCOPE: ${SO_OIDC_SCOPE:-openid profile email}
53+
OIDC_PROMPT: ${SO_OIDC_PROMPT:-}
5354
networks:
5455
- traefik
5556

docker-compose-prod-postgres.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ services:
5050
OIDC_REDIRECT_URI: ${SO_OIDC_REDIRECT_URI:-http://secobserve.localhost}
5151
OIDC_POST_LOGOUT_REDIRECT_URI: ${SO_OIDC_POST_LOGOUT_REDIRECT_URI:-http://secobserve.localhost}
5252
OIDC_SCOPE: ${SO_OIDC_SCOPE:-openid profile email}
53+
OIDC_PROMPT: ${SO_OIDC_PROMPT:-}
5354
networks:
5455
- traefik
5556

docker-compose-prod-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ services:
1717
OIDC_CLIENT_ID: ${SO_OIDC_CLIENT_ID:-dummy}
1818
OIDC_REDIRECT_URI: ${SO_OIDC_REDIRECT_URI:-http://localhost:3000}
1919
OIDC_POST_LOGOUT_REDIRECT_URI: ${SO_OIDC_POST_LOGOUT_REDIRECT_URI:-http://localhost:3000}
20+
OIDC_PROMPT: ${SO_OIDC_PROMPT:-}
2021
ports:
2122
- "3000:3000"
2223

docs/getting_started/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ A part of the configuration is done with environment variables, which need to be
4646
| `OIDC_REDIRECT_URI` | mandatory | The redirect URI is the URI the identity provider will send the security tokens back to. To be set with the URL of the frontend. |
4747
| `OIDC_POST_LOGOUT_REDIRECT_URI` | mandatory | The post logout redirect URI is the URI that will be called after logout. To be set with the URL of the frontend. |
4848
| `OIDC_SCOPE` | optional | OpenID Connect (OIDC) scopes are used by an application during authentication to authorize access to a user's details, like name or email. If the variable is not set, the standard scopes `openid profile email` will be used. |
49+
| `OIDC_PROMPT` | optional | The prompt parameter allows to request specific interactions with the user during the authentication process, values can be `none`, `login`, `consent` and `select_account`. Default is not to set the prompt parameter. |
4950

5051
All the `OIDC_*` environment variables are needed for technical reasons. If `OIDC_ENABLE` is set to `false`, the other `OIDC_*` environment variables can be set to `dummy` or something similar.
5152

docs/getting_started/upgrading.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
* There will be specific upgrade instructions if necessary, e.g. when there are new configuration parameters.
1212

13+
## Release 1.47.0
14+
15+
**Breaking changes**
16+
17+
* The OIDC attribute `prompt` is now configurable and it is not set as default. To return to the former behaviour, you have to set the environment variable `OIDC_PROMPT=select_account` for the frontend in your installation. For further details search for `prompt` in the [OpenID specification](https://openid.net/specs/openid-connect-core-1_0.html).
18+
19+
1320
## Release 1.46.0
1421

1522
**Breaking changes**

0 commit comments

Comments
 (0)