Skip to content

Commit 5de09f6

Browse files
authored
Merge pull request #40 from homebysix/1.7.0
v1.7.0 merge to master
2 parents c249a46 + f5a4b58 commit 5de09f6

5 files changed

Lines changed: 297 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# pre-commit-macadmin change log
2+
3+
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
4+
5+
6+
## [1.7.0] - 2020-10-06
7+
8+
### Added
9+
- Added pre-commit-macadmin change log (this file)
10+
- Ensure no superclass processors (e.g. URLGetter) are used, as these are intended to be referred to by other processors rather than directly used in recipes
11+
- Warn if setting a MinimumVersion greater than or equal to 2 in AutoPkg recipes, because some administrators may be running 1.4.1 and waiting for processor authors to add Python 3 compatibility
12+
- Validate `minimum_os_version` and `maximum_os_version` keys in Munki pkginfo files
13+
14+
### Changed
15+
- Set MinimumVersion needed for [C]URL* processors to 1.4, to ensure utilization of URLGetter
16+
- Updated valid Munki script shebangs to include Munki embedded Python symlink and path
17+
18+
19+
## [1.6.2] - 2020-01-20
20+
21+
### Fixed
22+
- Added missing sys module for Python version determination
23+
24+
25+
## [1.6.1] - 2019-12-26
26+
27+
### Fixed
28+
- Convert subprocess output to string
29+
30+
31+
## [1.6.0] - 2019-12-26
32+
33+
### Added
34+
- Validate possible values of RestartAction key in Munki pkginfo
35+
- New hook to check Git user email configuration (`git config user.email`)
36+
37+
38+
## [1.5.2] - 2019-11-26
39+
40+
### Fixed
41+
- Removed redundant EndOfCheckPhase check
42+
- Added URLGetter minimum version (although we should never need this since URLGetter is not meant to be called directly)
43+
44+
45+
## [1.5.1] - 2019-09-21
46+
47+
### Added
48+
- Checking for downloader processors without EndOfCheckPhase
49+
50+
51+
## [1.5.0] - 2019-09-17
52+
53+
### Added
54+
- Warn if using deprecated AutoPkg processors (only one exists now: CURLDownloader)
55+
- Allow specifying multiple acceptable recipe prefixes
56+
57+
### Fixed
58+
- Updated minimum AutoPkg versions required for processors to only include significant digits for LooseVersion comparison
59+
60+
61+
## [1.4.0] - 2019-08-22
62+
63+
### Added
64+
- Detect and warn on AutoPkg recipe identifier duplication
65+
- Warn if any Munki pkginfo script is missing a shebang
66+
67+
68+
## [1.3.0] - 2019-07-03
69+
70+
### Added
71+
- `--strict` mode for check-autopkg-recipes hook, along with numerous conventions that it can validate
72+
- Catch identifier loops, where recipe and its parent have the same identifier
73+
74+
### Fixed
75+
- Better handling of unicode
76+
- Fixed warning output when recipe list is invalid
77+
- Fixed shared FileWaveImporter processor identifier
78+
79+
### Changed
80+
- Handle recipe lists that have prefixes
81+
- Allow pkg recipes with no process (stubs for software already in pkg format at time of download)
82+
83+
84+
## [1.2.1] - 2019-06-28
85+
86+
### Added
87+
- Better parsing of MunkiPkg build-info files, and validation of keys
88+
- Better handle processors with missing Processor keys
89+
- Warn if MunkiPkg project target disk is not the startup disk
90+
- Validate required keys in MunkiPkg build-info files
91+
- Validate bundle identifier in MunkiPkg build-info files
92+
93+
94+
## [1.2.0] - 2019-06-27
95+
96+
### Added
97+
- Checking AutoPkg recipe processors for missing Processor key
98+
- Validation of EndOfCheckPhase placement within download recipes
99+
100+
### Changed
101+
- Created shared function for checking required keys for pkginfo files and AutoPkg recipes
102+
- No longer requiring an Input key for AutoPkg recipes
103+
104+
105+
## [1.1.4] - 2019-06-24
106+
107+
### Changed
108+
- Skip processor checks for AutoPkg recipes without a Process
109+
110+
111+
## [1.1.3] - 2019-06-24
112+
113+
### Added
114+
- Added `--ignore-min-vers-before` argument to check-autopkg-recipes hook
115+
- Added checking for `%NAME%.app` in check-autopkg-recipes hook
116+
117+
118+
## [1.1.2] - 2019-06-22
119+
120+
### Added
121+
- Added validation of AutoPkg recipe MinimumVersion in check-autopkg-recipes hook
122+
123+
### Changed
124+
- Fail early and stop processing files that don't parse
125+
126+
127+
## [1.1.1] - 2019-06-13
128+
129+
### Fixed
130+
- Fixed issue that returned wrong pass/fail result for check-munki-pkgsinfo and check-autopkg-recipes hooks
131+
132+
133+
## [1.1.0] - 2019-06-13
134+
135+
### Added
136+
- Added a note about combining list arguments in yaml config
137+
- Added note about multi-line list args
138+
- Ensure no trailing slashes on items_to_copy in check-munki-pkgsinfo
139+
140+
### Changed
141+
- Specified which yaml loader to use
142+
- Removed zip as an package extension
143+
144+
### Fixed
145+
- Fixed issue that caused incorrect pass/fail for check-munki-pkgsinfo and check-autopkg-recipes hooks
146+
147+
148+
## [1.0.5] - 2019-03-15
149+
150+
### Added
151+
- Added args documentation to read me
152+
153+
154+
## [1.0.4] - 2019-03-14
155+
156+
### Added
157+
- Added check for approved catalogs
158+
159+
160+
## [1.0.3] - 2019-03-13
161+
162+
### Fixed
163+
- Fixed variable capitalization
164+
165+
166+
## [1.0.2] - 2019-03-13
167+
168+
### Added
169+
- Enabled basic type checking for pkginfo dicts
170+
171+
### Changed
172+
- Adjusted required keys in check-munki-pkgsinfo to include name and description by default
173+
- Temporarily skipping top level plist type (dict) checking
174+
175+
176+
## [1.0.1] - 2019-03-03
177+
178+
### Added
179+
- Added forbid-autopkg-trust-info hook
180+
- Added check for recipe prefix enforcement
181+
182+
### Fixed
183+
- Fixed bug in check-autopkg-recipes hook
184+
185+
186+
## 1.0.0 - 2019-03-01
187+
188+
- Initial release
189+
190+
191+
[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.7.0...HEAD
192+
[1.6.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.6.2...v1.7.0
193+
[1.6.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.6.1...v1.6.2
194+
[1.6.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.6.0...v1.6.1
195+
[1.6.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.5.2...v1.6.0
196+
[1.5.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.5.1...v1.5.2
197+
[1.5.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.5.0...v1.5.1
198+
[1.5.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.4.0...v1.5.0
199+
[1.4.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.3.0...v1.4.0
200+
[1.3.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.2.1...v1.3.0
201+
[1.2.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.2.0...v1.2.1
202+
[1.2.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.1.4...v1.2.0
203+
[1.1.4]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.1.3...v1.1.4
204+
[1.1.3]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.1.2...v1.1.3
205+
[1.1.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.1.1...v1.1.2
206+
[1.1.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.1.0...v1.1.1
207+
[1.1.0]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.0.5...v1.1.0
208+
[1.0.5]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.0.4...v1.0.5
209+
[1.0.4]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.0.3...v1.0.4
210+
[1.0.3]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.0.2...v1.0.3
211+
[1.0.2]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.0.1...v1.0.2
212+
[1.0.1]: https://github.com/homebysix/pre-commit-macadmin/compare/v1.0.0...v1.0.1

README.md

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

1414
```yaml
1515
- repo: https://github.com/homebysix/pre-commit-macadmin
16-
rev: v1.6.2
16+
rev: v1.7.0
1717
hooks:
1818
- id: check-plists
1919
# - id: ...
@@ -119,7 +119,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat
119119

120120
```yaml
121121
- repo: https://github.com/homebysix/pre-commit-macadmin
122-
rev: v1.6.2
122+
rev: v1.7.0
123123
hooks:
124124
- id: check-munki-pkgsinfo
125125
args: ['--catalogs', 'testing', 'stable', '--']
@@ -129,7 +129,7 @@ But if you also use the `--categories` argument, you would move the trailing `--
129129

130130
```yaml
131131
- repo: https://github.com/homebysix/pre-commit-macadmin
132-
rev: v1.6.2
132+
rev: v1.7.0
133133
hooks:
134134
- id: check-munki-pkgsinfo
135135
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
@@ -141,7 +141,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu
141141

142142
```yaml
143143
- repo: https://github.com/homebysix/pre-commit-macadmin
144-
rev: v1.6.2
144+
rev: v1.7.0
145145
hooks:
146146
- id: check-munki-pkgsinfo
147147
args: [

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def validate_recipe_prefix(recipe, filename, prefix):
7171

7272

7373
def validate_comments(filename, strict):
74-
"""Warn about comments in <!-- --> format that would break during
75-
plutil -convert xml1."""
74+
"""Warn about comments in <!-- --> format that would break when running
75+
plutil -convert xml1."""
7676

7777
passed = True
7878
with open(filename, "r") as openfile:
@@ -151,6 +151,14 @@ def validate_endofcheckphase(process, filename):
151151
def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename):
152152
"""Ensure MinimumVersion is set appropriately for the processors used."""
153153

154+
# Warn if using a MinimumVersion greater than or equal to 2
155+
if LooseVersion(min_vers) >= LooseVersion("2"):
156+
print(
157+
"{}: WARNING: Choosing MinimumVersion {} limits the potential "
158+
"audience for your AutoPkg recipe. Consider using MinimumVersion "
159+
"1.4.1 if your processors support it.".format(filename, min_vers)
160+
)
161+
154162
# Processors for which a minimum version of AutoPkg is required.
155163
# Note: Because LooseVersion considers version 1.0 to be "less than" 1.0.0,
156164
# specifying more trailing zeros than needed in the dict below may result
@@ -159,8 +167,8 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
159167
"AppPkgCreator": "1.0",
160168
"BrewCaskInfoProvider": "0.2.5",
161169
"CodeSignatureVerifier": "0.3.1",
162-
"CURLDownloader": "0.5.1",
163-
"CURLTextSearcher": "0.5.1",
170+
"CURLDownloader": "1.4",
171+
"CURLTextSearcher": "1.4",
164172
"DeprecationWarning": "1.1",
165173
"EndOfCheckPhase": "0.1.0",
166174
"FileFinder": "0.2.3",
@@ -186,8 +194,9 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename)
186194
"StopProcessingIf": "0.1.0",
187195
"Symlinker": "0.1.0",
188196
"Unarchiver": "0.1.0",
197+
"URLDownloader": "1.4",
189198
"URLGetter": "1.4",
190-
"URLTextSearcher": "0.2.9",
199+
"URLTextSearcher": "1.4",
191200
"Versioner": "0.1.0",
192201
}
193202

@@ -225,6 +234,26 @@ def validate_no_deprecated_procs(process, filename):
225234
return passed
226235

227236

237+
def validate_no_superclass_procs(process, filename):
238+
"""Warn if any superclass processors (which are used by other processors
239+
rather than called in recipes) are used."""
240+
241+
# Processors that have been deprecated.
242+
superclass_procs = ("URLGetter",)
243+
244+
passed = True
245+
for proc in process:
246+
if proc.get("Processor") in superclass_procs:
247+
print(
248+
"{}: WARNING: The processor {} is intended to be used "
249+
"by other processors, not used directly in recipes.".format(
250+
filename, proc.get("Processor")
251+
)
252+
)
253+
254+
return passed
255+
256+
228257
def validate_no_var_in_app_path(process, filename):
229258
"""Ensure %NAME% is not used in app paths that should be hard coded."""
230259

@@ -396,6 +425,26 @@ def main(argv=None):
396425
if not validate_restart_action_key(input_key["pkginfo"], filename):
397426
retval = 1
398427

428+
# Check for common mistakes in min/max OS version keys
429+
os_vers_corrections = {
430+
"min_os": "minimum_os_version",
431+
"max_os": "maximum_os_version",
432+
"min_os_vers": "minimum_os_version",
433+
"max_os_vers": "maximum_os_version",
434+
"minimum_os": "minimum_os_version",
435+
"maximum_os": "maximum_os_version",
436+
"minimum_os_vers": "minimum_os_version",
437+
"maximum_os_vers": "maximum_os_version",
438+
}
439+
for os_vers_key in os_vers_corrections:
440+
if os_vers_key in input_key["pkginfo"]:
441+
print(
442+
"{}: You used {} when you probably meant {}.".format(
443+
filename, os_vers_key, os_vers_corrections[os_vers_key]
444+
)
445+
)
446+
retval = 1
447+
399448
# TODO: Additional pkginfo checks here.
400449

401450
# Warn about comments that would be lost during `plutil -convert xml1`
@@ -424,6 +473,9 @@ def main(argv=None):
424473
if not validate_no_deprecated_procs(process, filename):
425474
retval = 1
426475

476+
if not validate_no_superclass_procs(process, filename):
477+
retval = 1
478+
427479
if args.strict:
428480
if not validate_proc_type_conventions(process, filename):
429481
retval = 1

0 commit comments

Comments
 (0)