Skip to content

Commit dcf837e

Browse files
authored
Merge pull request #83 from homebysix/1.17.0
1.17.0 merge to main
2 parents 7314aab + 9f23280 commit dcf837e

File tree

9 files changed

+110
-27
lines changed

9 files changed

+110
-27
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-ast
66
- id: check-byte-order-marker
@@ -16,11 +16,19 @@ repos:
1616
- id: trailing-whitespace
1717
args: [--markdown-linebreak-ext=md]
1818
- repo: https://github.com/asottile/pyupgrade
19-
rev: v3.16.0
19+
rev: v3.19.1
2020
hooks:
2121
- id: pyupgrade
2222
args: ['--py36-plus']
23+
- repo: https://github.com/pycqa/flake8
24+
rev: 7.1.1
25+
hooks:
26+
- id: flake8
27+
- repo: https://github.com/pycqa/isort
28+
rev: 5.13.2
29+
hooks:
30+
- id: isort
2331
- repo: https://github.com/python/black
24-
rev: 24.4.2
32+
rev: 24.10.0
2533
hooks:
2634
- id: black

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ All notable changes to this project will be documented in this file. This projec
1414

1515
Nothing yet.
1616

17+
## [1.17.0] - 2024-12-22
18+
19+
### Added
20+
21+
- New `--warn-on-duplicate-imports` flag for use with Munki pkginfo checks, for Munki administrators who don't care about multiple potential versions of the same pkginfo/pkg in the repository (perhaps because of differing `supported_architectures` or other keys).
22+
23+
When this is specified, the pre-commit hook will warn when files with `__1` (and similar) suffixes are seen in the pkgsinfo/pkgs folders. This will enbale pre-commit hooks to pass, as long as there are no other errors. Omitting the `--warn-on-duplicate-imports` flag will continue generating an error and failing the hooks, as was the previous behavior.
24+
25+
- Include `SignToolVerifier` and `URLDownloaderPython` AutoPkg processors when suggesting minimum versions.
26+
- Updated AutoPkg recipe type convention checking to include new `JamfUpload` processors as well as `URLDownloaderPython` and `MunkiInfoCreator`.
27+
- Added a suggestion to use Rich Trouton's [VariablePlaceholder](https://derflounder.wordpress.com/2024/08/16/setting-custom-variables-in-autopkg-using-the-variableplaceholder-processor/) processor for setting arbitrary environment variables instead of supplying unexpected arguments to existing processors.
28+
29+
### Fixed
30+
31+
- Fixed FileWaveImporter processor detection.
32+
1733
## [1.16.2] - 2024-06-10
1834

1935
### Fixed
@@ -367,7 +383,8 @@ Nothing yet.
367383

368384
- Initial release
369385

370-
[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.16.2...HEAD
386+
[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.17.0...HEAD
387+
[1.17.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.16.2...v1.17.0
371388
[1.16.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.16.1...v1.16.2
372389
[1.16.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.15.0...v1.16.1
373390
[1.15.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.14.1...v1.15.0

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit
1515

1616
```yaml
1717
- repo: https://github.com/homebysix/pre-commit-macadmin
18-
rev: v1.16.2
18+
rev: v1.17.0
1919
hooks:
2020
- id: check-plists
2121
# - id: ...
@@ -61,18 +61,18 @@ After adding a hook to your pre-commit config, it's not a bad idea to run `pre-c
6161
This hook checks AutoPkg recipes to ensure they meet various requirements and conventions.
6262

6363
- Optionally specify your preferred AutoPkg recipe and/or override prefix, if you wish to enforce them:
64-
`args: ['--override-prefix=com.yourcompany.autopkg.']`
65-
(default: `local.`)
66-
`args: ['--recipe-prefix=com.github.yourusername.']`
64+
`args: ['--override-prefix=com.yourcompany.autopkg.']`
65+
(default: `local.`)
66+
`args: ['--recipe-prefix=com.github.yourusername.']`
6767
(default: `com.github.`)
6868

6969
- Optionally specify the version of AutoPkg for which you want to ignore MinimumVersion mismatches with processors.
70-
`args: ['--ignore-min-vers-before=0.5.0']`
71-
(default: `1.0.0`)
70+
`args: ['--ignore-min-vers-before=0.5.0']`
71+
(default: `1.0.0`)
7272
Specifying `0.1.0` will not ignore any MinimumVersion mismatches.
7373

74-
- If you're a purist, you can also enable strict mode. This enforces recipe type conventions, all processor/MinimumVersion mismatches, forbids `<!-- -->` style comments, and ensures all processor input variables (arguments) are valid.
75-
`args: ['--strict']`
74+
- If you're a purist, you can also enable strict mode. This enforces recipe type conventions, all processor/MinimumVersion mismatches, forbids `<!-- -->` style comments, and ensures all processor input variables (arguments) are valid.
75+
`args: ['--strict']`
7676
(default: False)
7777

7878
- __forbid-autopkg-overrides__
@@ -117,9 +117,12 @@ After adding a hook to your pre-commit config, it's not a bad idea to run `pre-c
117117
`args: ['--munki-repo', './my_repo_location']`
118118
(default: ".")
119119

120-
- Choose to just warn on missing icons with a flag, note if no other issues exist this will allow pre-commit to pass without seeing the warnings:
120+
- Choose to just warn if icons referenced in pkginfo files are missing (this will allow pre-commit checks to pass if no other issues exist):
121121
`args: ['--warn-on-missing-icons]`
122122

123+
- Choose to just warn if pkg/pkginfo files with __1 (or similar) suffixes are detected (this will allow pre-commit checks to pass if no other issues exist):
124+
`args: ['--warn-on-duplicate-imports]`
125+
123126
- Add additional shebangs that are valid for your environment:
124127
`args: ['--valid-shebangs', '#!/bin/macadmin/python37', '#!/bin/macadmin/python42', '--']`
125128

@@ -141,7 +144,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat
141144

142145
```yaml
143146
- repo: https://github.com/homebysix/pre-commit-macadmin
144-
rev: v1.16.2
147+
rev: v1.17.0
145148
hooks:
146149
- id: check-munki-pkgsinfo
147150
args: ['--catalogs', 'testing', 'stable', '--']
@@ -151,7 +154,7 @@ But if you also use the `--categories` argument, you would move the trailing `--
151154

152155
```yaml
153156
- repo: https://github.com/homebysix/pre-commit-macadmin
154-
rev: v1.16.2
157+
rev: v1.17.0
155158
hooks:
156159
- id: check-munki-pkgsinfo
157160
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
@@ -163,7 +166,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu
163166

164167
```yaml
165168
- repo: https://github.com/homebysix/pre-commit-macadmin
166-
rev: v1.16.2
169+
rev: v1.17.0
167170
hooks:
168171
- id: check-munki-pkgsinfo
169172
args: [

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import sys
88
from contextlib import contextmanager
9+
910
from packaging.version import Version
1011

1112
from pre_commit_hooks.util import (
@@ -86,7 +87,11 @@ def validate_recipe_prefix(recipe, filename, prefix):
8687
print(
8788
"{}: identifier does not start with {}".format(
8889
filename,
89-
'one of: "%s"' % '", "'.join(prefix) if len(prefix) > 1 else prefix[0],
90+
(
91+
'one of: "%s"' % '", "'.join(prefix)
92+
if len(prefix) > 1
93+
else prefix[0]
94+
),
9095
)
9196
)
9297
passed = False
@@ -174,13 +179,19 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
174179
# Processors for which a minimum version of AutoPkg is required.
175180
# Note: packaging.version.Version considers this True: "1.0" == "1.0.0"
176181
proc_min_versions = {
182+
"AppDmgVersioner": "0.0",
177183
"AppPkgCreator": "1.0",
178184
"BrewCaskInfoProvider": "0.2.5",
185+
# "ChocolateyPackager": "3.0", # hasn't been merged yet
179186
"CodeSignatureVerifier": "0.3.1",
187+
"Copier": "0.0",
180188
"CURLDownloader": "0.5.1",
181189
"CURLTextSearcher": "0.5.1",
182190
"DeprecationWarning": "1.1",
191+
"DmgCreator": "0.0",
192+
"DmgMounter": "0.0",
183193
"EndOfCheckPhase": "0.1.0",
194+
"FileCreator": "0.0",
184195
"FileFinder": "0.2.3",
185196
"FileMover": "0.2.9",
186197
"FlatPkgPacker": "0.2.4",
@@ -190,21 +201,28 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
190201
"InstallFromDMG": "0.4.0",
191202
"MunkiCatalogBuilder": "0.1.0",
192203
"MunkiImporter": "0.1.0",
204+
"MunkiInfoCreator": "0.0",
193205
"MunkiInstallsItemsCreator": "0.1.0",
194206
"MunkiOptionalReceiptEditor": "2.7",
195207
"MunkiPkginfoMerger": "0.1.0",
196208
"MunkiSetDefaultCatalog": "0.4.2",
197209
"PackageRequired": "0.5.1",
198210
"PathDeleter": "0.1.0",
199211
"PkgCopier": "0.1.0",
212+
"PkgCreator": "0.0",
200213
"PkgExtractor": "0.1.0",
214+
"PkgInfoCreator": "0.0",
201215
"PkgPayloadUnpacker": "0.1.0",
216+
"PkgRootCreator": "0.0",
202217
"PlistEditor": "0.1.0",
203218
"PlistReader": "0.2.5",
219+
"SignToolVerifier": "2.3",
204220
"SparkleUpdateInfoProvider": "0.1.0",
205221
"StopProcessingIf": "0.1.0",
206222
"Symlinker": "0.1.0",
207223
"Unarchiver": "0.1.0",
224+
"URLDownloader": "0.0",
225+
"URLDownloaderPython": "2.4.1",
208226
"URLTextSearcher": "0.2.9",
209227
"Versioner": "0.1.0",
210228
}
@@ -367,10 +385,12 @@ def validate_proc_type_conventions(process, filename):
367385
"SparkleUpdateInfoProvider",
368386
"GitHubReleasesInfoProvider",
369387
"URLDownloader",
388+
"URLDownloaderPython",
370389
"CURLDownloader",
371390
"EndOfCheckPhase",
372391
],
373392
"munki": [
393+
"MunkiInfoCreator",
374394
"MunkiInstallsItemsCreator",
375395
"MunkiPkginfoMerger",
376396
"MunkiCatalogBuilder",
@@ -384,18 +404,35 @@ def validate_proc_type_conventions(process, filename):
384404
"jss": ["JSSImporter"],
385405
# https://github.com/grahampugh/jamf-upload
386406
"jamf": [
407+
"com.github.grahampugh.jamf-upload.processors/JamfAccountUploader",
387408
"com.github.grahampugh.jamf-upload.processors/JamfCategoryUploader",
409+
"com.github.grahampugh.jamf-upload.processors/JamfClassicAPIObjectUploader",
388410
"com.github.grahampugh.jamf-upload.processors/JamfComputerGroupUploader",
389411
"com.github.grahampugh.jamf-upload.processors/JamfComputerProfileUploader",
412+
"com.github.grahampugh.jamf-upload.processors/JamfDockItemUploader",
390413
"com.github.grahampugh.jamf-upload.processors/JamfExtensionAttributeUploader",
414+
"com.github.grahampugh.jamf-upload.processors/JamfIconUploader",
415+
"com.github.grahampugh.jamf-upload.processors/JamfMacAppUploader",
416+
"com.github.grahampugh.jamf-upload.processors/JamfMobileDeviceGroupUploader",
417+
"com.github.grahampugh.jamf-upload.processors/JamfMobileDeviceProfileUploader",
418+
"com.github.grahampugh.jamf-upload.processors/JamfPackageCleaner",
391419
"com.github.grahampugh.jamf-upload.processors/JamfPackageUploader",
420+
"com.github.grahampugh.jamf-upload.processors/JamfPatchChecker",
421+
"com.github.grahampugh.jamf-upload.processors/JamfPatchUploader",
392422
"com.github.grahampugh.jamf-upload.processors/JamfPolicyDeleter",
423+
"com.github.grahampugh.jamf-upload.processors/JamfPolicyLogFlusher",
393424
"com.github.grahampugh.jamf-upload.processors/JamfPolicyUploader",
394425
"com.github.grahampugh.jamf-upload.processors/JamfScriptUploader",
395426
"com.github.grahampugh.jamf-upload.processors/JamfSoftwareRestrictionUploader",
427+
"com.github.grahampugh.jamf-upload.processors/JamfUploaderSlacker",
428+
"com.github.grahampugh.jamf-upload.processors/JamfUploaderTeamsNotifier",
396429
],
397430
# https://github.com/autopkg/filewave
398-
"filewave": ["FileWaveImporter"],
431+
"filewave": [
432+
"com.github.autopkg.filewave.FWTool/FileWaveImporter",
433+
"com.github.johncclayton.filewave.FWTool/FileWaveImporter",
434+
"com.github.autopkg.filewave.FWTool/FWTool",
435+
],
399436
}
400437

401438
passed = True
@@ -489,17 +526,23 @@ def validate_proc_args(process, filename):
489526
# Skip args in ignored list above.
490527
continue
491528

529+
suggestion = (
530+
"Consider using the VariablePlaceholder processor for adding custom environment variables:\n"
531+
"https://derflounder.wordpress.com/2024/08/16/setting-custom-variables-in-autopkg-using-the-variableplaceholder-processor/"
532+
)
492533
if not core_procs[proc["Processor"]]:
493534
print(
494535
f"{filename}: Unknown argument {arg} for processor {proc['Processor']}, "
495536
"which does not accept any arguments."
496537
)
538+
print(suggestion)
497539
passed = False
498540
elif arg not in core_procs[proc["Processor"]]:
499541
print(
500542
f"{filename}: Unknown argument {arg} for processor {proc['Processor']}. Allowed arguments are: "
501543
+ ", ".join(core_procs[proc["Processor"]])
502544
)
545+
print(suggestion)
503546
passed = False
504547

505548
return passed

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from pathlib import Path
88
from xml.parsers.expat import ExpatError
99

10-
1110
from pre_commit_hooks.util import (
1211
validate_pkginfo_key_types,
1312
validate_required_keys,
@@ -45,6 +44,12 @@ def build_argument_parser():
4544
action="store_true",
4645
default=False,
4746
)
47+
parser.add_argument(
48+
"--warn-on-duplicate-imports",
49+
help="If added, this will only warn if pkginfo/pkg files end with a __1 suffix.",
50+
action="store_true",
51+
default=False,
52+
)
4853
parser.add_argument(
4954
"--valid-shebangs",
5055
nargs="+",
@@ -67,7 +72,7 @@ def _check_case_sensitive_path(path):
6772
if p == p.parent:
6873
return True
6974
# If string representation of path is not in parent directory, return False
70-
if str(p) not in map(str, p.parent.iterdir()):
75+
if str(p) not in list(map(str, p.parent.iterdir())):
7176
return False
7277
p = p.parent
7378

@@ -154,10 +159,15 @@ def main(argv=None):
154159

155160
# Check for pkg filenames showing signs of duplicate imports.
156161
if pkginfo.get("installer_item_location", "").endswith(tuple(dupe_suffixes)):
157-
print(
158-
f'{filename}: installer item "{pkginfo.get("installer_item_location")}" may be a duplicate import'
162+
installer_item_location = pkginfo["installer_item_location"]
163+
msg = (
164+
f"installer item '{installer_item_location}' may be a duplicate import"
159165
)
160-
retval = 1
166+
if args.warn_on_missing_icons:
167+
print(f"{filename}: WARNING: {msg}")
168+
else:
169+
print(f"{filename}: {msg}")
170+
retval = 1
161171

162172
# Checking for the absence of blocking_applications for pkg installers.
163173
# If a pkg doesn't require blocking_applications, use empty "<array/>" in pkginfo.
@@ -184,10 +194,11 @@ def main(argv=None):
184194
pkginfo.get("installer_type") == "apple_update_metadata",
185195
)
186196
):
197+
msg = "missing icon"
187198
if args.warn_on_missing_icons:
188-
print(f"WARNING: {filename}: missing icon")
199+
print(f"{filename}: WARNING: {msg}")
189200
else:
190-
print(f"{filename}: missing icon")
201+
print(f"{filename}: {msg}")
191202
retval = 1
192203

193204
# Ensure uninstall method is set correctly if uninstall_script exists.

pre_commit_hooks/check_munkipkg_buildinfo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from xml.parsers.expat import ExpatError
99

1010
import ruamel.yaml
11+
1112
from pre_commit_hooks.util import validate_required_keys
1213

1314
yaml = ruamel.yaml.YAML(typ="safe")

pre_commit_hooks/forbid_autopkg_trust_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
repo."""
44

55
import argparse
6+
67
from pre_commit_hooks.util import load_autopkg_recipe
78

89

pre_commit_hooks/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import plistlib
5-
import sys
65
from datetime import datetime
76

87
import ruamel.yaml

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name="pre-commit-macadmin",
77
description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.",
88
url="https://github.com/homebysix/pre-commit-macadmin",
9-
version="1.16.2",
9+
version="1.17.0",
1010
author="Elliot Jordan",
1111
author_email="[email protected]",
1212
packages=["pre_commit_hooks"],

0 commit comments

Comments
 (0)