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

Fix macOS 14.7 build parsing #1059

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions tests/inventory/test_macos_build_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def test_ok(self):
("23D60", ("macOS", 14, 3, 1, None), "macOS 14.3.1 (23D60)"),
("23E214", ("macOS", 14, 4, 0, None), "macOS 14.4 (23E214)"),
("23G93", ("macOS", 14, 6, 1, None), "macOS 14.6.1 (23G93)"),
("23H124", ("macOS", 14, 7, 0, None), "macOS 14.7 (23H124)"),
("24A335", ("macOS", 15, 0, 0, None), "macOS 15.0 (24A335)"),
):
expected_version_d = {
"name": name,
Expand Down
2 changes: 1 addition & 1 deletion tests/santa/test_setup_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def test_post_update_configuration_view(self, post_event):
"remount_usb_mode": "rdonly, noexec",
"voting_realm": realm.pk,
"banned_threshold": -50,
"default_ballot_target_types": "METABUNDLE,SIGNINGID",
"default_ballot_target_types": ["METABUNDLE", "SIGNINGID"],
"default_voting_weight": 1,
"globally_allowlisted_threshold": 500,
"partially_allowlisted_threshold": 100,
Expand Down
2 changes: 1 addition & 1 deletion zentral/contrib/inventory/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def macos_version_from_build(build):
patch = 0
if patch_letter >= "G" and major == 12 and patch_number >= 816:
minor = 7
elif patch_letter >= "G" and patch_number >= 115:
elif patch_letter >= "G" and major in (12, 13) and patch_number >= 115:
minor = 6
elif minor > 0 and major < 14:
minor -= 1
Expand Down
14 changes: 13 additions & 1 deletion zentral/contrib/santa/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@
logger = logging.getLogger("zentral.contrib.santa.forms")


class TargetTypesWidget(forms.CheckboxSelectMultiple):
def __init__(self, attrs=None, choices=()):
super().__init__(attrs, choices=Target.Type.choices)

def format_value(self, value):
if isinstance(value, str) and value:
value = [v.strip() for v in value.split(",")]
return super().format_value(value)


class ConfigurationForm(forms.ModelForm):
class Meta:
model = Configuration
fields = '__all__'
widgets = {
"default_ballot_target_types": TargetTypesWidget,
"event_detail_url": forms.Textarea(attrs={"cols": "40", "rows": "3"}),
"allowed_path_regex": forms.Textarea(attrs={"cols": "40", "rows": "3"}),
"blocked_path_regex": forms.Textarea(attrs={"cols": "40", "rows": "3"})
Expand Down Expand Up @@ -73,6 +84,7 @@ class Meta:
"ballot_target_types",
"voting_weight"
)
widgets = {"ballot_target_types": TargetTypesWidget}

def __init__(self, *args, **kwargs):
self.configuration = kwargs.pop("configuration")
Expand Down Expand Up @@ -1023,7 +1035,7 @@ def results(self, current_username, current_email, offset, limit):

for key, display_str in Target.objects.get_targets_display_strings(targets.keys()).items():
for idx in targets[key]:
results[idx][f"target_display_str"] = display_str
results[idx]["target_display_str"] = display_str

return results

Expand Down
Loading