1
1
2
2
# How to contribute
3
3
4
- You can use this document not only to see how to contribute code but also to prepare yourself to
5
- extend this firewall project for your own personal or corporate needs.
4
+ You can use this document not only to see how to contribute code but also to prepare yourself to\
5
+ extend this firewall for your personal or corporate needs.
6
6
7
7
Here is a list of most important things to keep in mind.
8
8
@@ -27,7 +27,7 @@ Here is a list of most important things to keep in mind.
27
27
- [ Portability and other systems] ( #portability-and-other-systems )
28
28
- [ Making new scripts or modules] ( #making-new-scripts-or-modules )
29
29
- [ Repository folder structure] ( #repository-folder-structure )
30
- - [ Final notes and where to start] ( #final-notes-and- where-to-start )
30
+ - [ Where to start] ( #where-to-start )
31
31
32
32
## General guidelines
33
33
@@ -69,8 +69,8 @@ It is highly recommended to stick with Visual Studio Code, because this project
69
69
specific to Visual Studio Code, aka. "Workspace", these settings include:
70
70
71
71
1 . Code formatting settings which are automatically enforced, and can also be manually applied
72
- 2 . List of recommended extensions which are automatically listed for installation when you open
73
- project root folder
72
+ 2 . List of recommended extensions which are automatically listed for installation once you open\
73
+ repository root folder with VSCode
74
74
3 . Debugging and code analysis settings which you can use to debug code
75
75
4 . Settings for recommended extensions, ex. markdown and script formatting
76
76
5 . Spelling settings such as random good words which would be detected as misspelled.
@@ -111,33 +111,39 @@ Recommended extensions in workspace are as follows:
111
111
Firewall rules can be exported into CSV file, this extension provides syntax highlighting for
112
112
CSV files
113
113
114
- 8 . [ GitLens] [ extension gitlens ]
115
-
116
- It provides so many great features for git inside VSCode it can't be explained in one line
117
-
118
- 9 . [ Markdown All in One] [ extension markdown aio ]
114
+ 8 . [ Markdown All in One] [ extension markdown aio ]
119
115
120
116
Provides markdown language features
121
117
122
- 10 . [ XML Tools] [ extension xml ]
118
+ 9 . [ XML Tools] [ extension xml ]
123
119
124
120
Useful module xml files navigation
125
121
126
- 11 . [ Log File Highlighter] [ extension logs ]
122
+ 10 . [ Log File Highlighter] [ extension logs ]
127
123
128
124
Custom syntax highlighting for log files, useful for firewall logs as an alternative of mTail.
129
125
This extension complements "Auto Scroll"
130
126
131
- 12 . [ Auto Scroll] [ extension scroll ]
127
+ 11 . [ Auto Scroll] [ extension scroll ]
132
128
133
129
Automatic scrolling of log files, useful to tail firewall logs.
134
130
This extension complements "Log File Highlighter"
135
131
136
- 13 . [ Filter Line] [ extension filterline ]
132
+ 12 . [ Filter Line] [ extension filterline ]
137
133
138
134
Filter log files according to json config, string or regex pattern
139
135
140
- The continuation of before mentioned link for PowerShell, gpg, ssh etc. is to visit ` Config\ProjectSettings.ps1 `
136
+ Following 2 extensions are optional and will not be automatically offerred for installation:
137
+
138
+ - [ GitLens] [ extension gitlens ]
139
+
140
+ It provides so many great features for git inside VSCode it can't be explained in one line
141
+
142
+ - [ GitHub Pull Requests and Issues] [ pull requests ]
143
+
144
+ Review and manage your GitHub pull requests and issues directly in VS Code
145
+
146
+ The continuation of before mentioned tutorial for PowerShell, gpg, ssh etc. is to visit ` Config\ProjectSettings.ps1 `
141
147
located in project root directory, at a minimum you should set following variables to ` $true `
142
148
before doing anything else:
143
149
@@ -149,12 +155,12 @@ before doing anything else:
149
155
6 . WarningLogging
150
156
151
157
Note that some of these may be auto adjusted after setting ` Develop ` to ` $true ` \
152
- Then restart PowerShell and run ` .\SetupFirewall.ps1 ` to apply firewall, or at least run
158
+ Then restart PowerShell and run ` .\SetupFirewall.ps1 ` to deploy firewall, or at least run
153
159
` Initialize-Project ` function which will prompt you to perform recommended and required checks.
154
160
155
161
Detailed description of variables is located in ` Config\ProjectSettings.ps1 `
156
162
157
- After project was intialized ` ProjectCheck ` variable should be disabled, logging variables can be
163
+ Once repository was intialized ` ProjectCheck ` variable should be disabled, logging variables can be
158
164
disabled too.
159
165
160
166
If you don't have this environment setup, you'll have to do this some other way around for your
@@ -171,7 +177,7 @@ Lines should be kept within 100-120 columns, however it is not always practical,
171
177
rule, workspace settings are configured to show rulers inside code editor.
172
178
173
179
If you use some other code editor you should configure it according to these rules which are found
174
- in ` .vscode ` , ` Config ` and project root directory.
180
+ in ` .vscode ` , ` Config ` and repository root directory.
175
181
176
182
Not everything is automatically formatted, in short:\
177
183
Use ** PascalCase** for variables, types, symbols etc; ** lowercase** for language keywords,
@@ -238,6 +244,8 @@ easily customized without too much change or learning curve.
238
244
3rd party code/scripts are dot sourced into existing modules instead of copy pasted into module
239
245
directly, this must be so, to easily see to which file does license/Copyright apply in full.
240
246
247
+ Exception to this rule are complete modules which should retain their directory domain within repository.
248
+
241
249
## Module design
242
250
243
251
Rules for code in modules is different, most important is to keep each function in it's own script,
@@ -273,7 +281,7 @@ Invoke-ScriptAnalyzer -Path .\ -Recurse -Settings Config\PSScriptAnalyzerSetting
273
281
274
282
If you get an error such as:\
275
283
` Invoke-ScriptAnalyzer: Object reference not set to an instance of an object. ` \
276
- then try again and keep repeating until OK.
284
+ then try again and keep repeating until OK, or cleanup repository and restart VSCode .
277
285
278
286
## Documentation and comments
279
287
@@ -282,11 +290,11 @@ Documentation and comments reside in 6 places as follows:
282
290
1 . In scripts (code comments)
283
291
284
292
Sections of code should be documented as shown in existing scripts.\
285
- To comment on things that need to be done add " TODO:" + comment,
286
- similarly for important notes add " NOTE:" + comment.
293
+ To comment on things that need to be done add ` TODO: ` + comment,
294
+ similarly for important notes add ` NOTE: ` + comment.
287
295
288
- For things which are hard to resolve add " HACK:" + comment, and optionally some links such as
289
- github issues that may help to resolve problem in the future.
296
+ For things which are hard to resolve or require huge changes add ` HACK: ` + comment, and
297
+ optionally some links such as github issues that may help to resolve problem in the future.
290
298
291
299
For any generic code comments you might want to add, use line comments (preferred) and
292
300
block comments only if comment spans 10 or more lines.
@@ -304,27 +312,29 @@ Documentation and comments reside in 6 places as follows:
304
312
305
313
Each of these prompts have ` ? ` which the user can type to get more information about prompt choices.
306
314
307
- 4 . In comment based help (module main documentation source)
315
+ 4 . In comment based help (module and script main documentation source)
308
316
309
- Functions that are part of a module must have comment based help.\
310
- Purpose of comment based help is for module user to be able to run ` Get-Help ` on target function.
317
+ Functions that are part of a module or solo scripts must have comment based help.\
318
+ Purpose of comment based help is for the end user to learn what the codes does or to be able to
319
+ run ` Get-Help ` on target function or script.
311
320
312
- For examples and comment based syntax see:
321
+ For examples, and comment based syntax see:
313
322
- [ About Comment-based Help] [ about comment based help ]
314
323
- [ Examples of Comment-Based Help] [ comment based help examples ]
315
324
316
325
You must avoid following comment based content to avoid errors while generating online help files:
317
326
- .LINK entries must contains only one link and nothing else
318
327
- Avoid dashes in comments such as ` ------ `
328
+ - Avoid lines starting with a backslash ` \ ` or any non alphanumeric character
319
329
320
330
5 . In module Help folder (module online documentation)
321
331
322
- The ` Scripts ` folder contains ` UpdateHelp.ps1 ` which when run will scan comment based help and
323
- generate online documentation for ` Get-Help -Online ` and help content for ` Update-Help ` on
332
+ The ` Scripts ` folder contains ` UpdateHelp.ps1 ` which when run will scan comment based help and\
333
+ generate online documentation for ` Get-Help -Online ` and help content for ` Update-Help ` on\
324
334
target module.
325
335
326
- Generated module documentation is of markdown format, meaning the 3rd purpose is that project
327
- users and repository visitors can read module documentation on github site.
336
+ Generated module documentation is in markdown format, meaning the 3rd purpose is that project
337
+ users and repository visitors can read module documentation on github site with ` Get-Help -Online `
328
338
329
339
6 . In Readme folder (general project documentation)
330
340
@@ -347,19 +357,20 @@ no explanation what is this supposed to allow or block is not acceptable.
347
357
348
358
## Testing code
349
359
350
- Each function should have it's own test script and each test should cover as much code/test
360
+ Each function should have it's own unit test and each test should cover as much code/test
351
361
cases as possible, making changes to exiting code can then be easily tested.\
352
362
If test case/concept expands to several functions or if it's completely
353
363
unrelated to functions it should be a separate test.
354
364
355
- All tests reside in " Test" folder which contains subfolders for each module,
365
+ All tests reside in ` Test ` directory which contains subdirectories for each module,
356
366
take a look there for examples.
357
367
358
- Pester is preferred method to write tests, however some testings needs other way around, or
368
+ Pester is preferred method to write tests, however some test cases needs other ways around, or
359
369
more specialized setup.
360
370
361
- There is a module called "Ruleset.Test", which is customized for this project.\
362
- Tests must pass both Desktop and Core editions of PowerShell to be successful
371
+ There is a module called ` Ruleset.Test ` , which is customized for this project.\
372
+ Tests must pass both Desktop and Core editions of PowerShell on multiple Windows editions to be
373
+ successful
363
374
364
375
A hint to quickly run any function from any project module is to run following command in ex.
365
376
integrated terminal in VSCode (assuming PowerShell prompt is at project root):
@@ -375,44 +386,45 @@ This will add all repository `Modules` to current session module path
375
386
Push small commits that solve or improve single or specific problem,
376
387
to reduce merge conflicts and to be able to do ` git revert ` for specific stuff.
377
388
378
- Do not wait too much to push large commits which are not clear enough in terms
389
+ Do not wait too much to push large commits which are then not clear enough in terms
379
390
of what issue is supposed to be resolved or which component was improved.
380
391
381
- If you see something unrelated that could be resolved, put TODO commont , don't fix it.\
382
- Then once you commit open todo-tree to review what to do next.
392
+ If you see something unrelated that could be resolved, put ` TODO ` comment , don't fix it.\
393
+ Then once you commit, open ` todo-tree ` to review what to do next.
383
394
384
- ** Avoid making huge changes to existing code** without first discussing the matter ,
395
+ ** Please avoid making huge changes to existing code** without first attaching valid reasons ,
385
396
new code and additions is not problem though.
386
397
387
398
## Portability and other systems
388
399
389
- At the moment the focus is on Windows Firewall, if you want to port code to other firewalls go ahead.
400
+ At the moment the focus is on Windows Firewall, if you want to extend code base to other firewalls
401
+ go ahead, it surely won't be easy!
390
402
391
- If you decide to port code it is mandatory that these code changes are done on separate branch.
403
+ If you decide to do so it is mandatory that these code additions are done on separate branch, which
404
+ should then be regularly maintained for any changes on master branch, up until you are done.
392
405
393
- The plan is to expand this project to manage [ nftables] [ nftables ]
394
- firewall on linux and other systems.
406
+ The plan is to expand this project to manage [ nftables] [ nftables ] firewall on linux and other systems.
395
407
396
408
## Making new scripts or modules
397
409
398
410
Inside ` Templates ` folder there are few template scripts as a starting point.\
399
- Copy them to target location, update starting code and you're ready to start writing .
411
+ Copy them to target location, update starting code and you're ready to start working .
400
412
401
413
These templates are fully aligned to rule design, code and formatting style of this project.
402
414
403
415
## Repository folder structure
404
416
405
417
See [ Directory Structure] ( Readme/DirectoryStructure.md )
406
418
407
- ## Final notes and where to start
419
+ ## Where to start
408
420
409
- Please keep in mind that large amount of existing code is not in line with all the guidelines
410
- described here, significant portion of code was written before this " CONTRIBUTING" file even existed.
421
+ Please keep in mind that large amount of existing code is not in line with all the guidelines described
422
+ here, significant portion of the code was written before this ` CONTRIBUTING.md ` file even existed.
411
423
412
424
So it's an ongoing effort that by no means gets fulfilled.
413
425
414
- I recommend you start at looking into [ TODO] ( Readme/TODO.md ) list and also use " todo-tree"
415
- extension to see even more todo's, unless you have specific ideas or recommendations.
426
+ I recommend you start at looking into [ TODO] ( Readme/TODO.md ) list and also use ` todo-tree `
427
+ extension to see more specific or smaller todo's, unless you have specific ideas or recommendations.
416
428
417
429
[ contributing develop ] : https://github.com/metablaster/WindowsFirewallRuleset/blob/develop/CONTRIBUTING.md " latest CONTRIBUTING.md "
418
430
[ contribute to open source ] : https://opensource.guide/how-to-contribute " How to contribute to open source "
@@ -448,3 +460,4 @@ extension to see even more todo's, unless you have specific ideas or recommendat
448
460
[ comment based help examples ] : https://docs.microsoft.com/en-us/powershell/scripting/developer/help/examples-of-comment-based-help?view=powershell-7 " Visit documentation "
449
461
[ iana ] : https://www.iana.org " Internet Assigned Numbers Authority (IANA) "
450
462
[ nftables ] : https://en.wikipedia.org/wiki/Nftables " Visit nftables wiki "
463
+ [ pull requests ] : https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github " Visit Marketplace "
0 commit comments