-
Notifications
You must be signed in to change notification settings - Fork 2
Describe Block Update Fix #21
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
44041c8
fix return value in updates.ts, there are 3 test failing for getExist…
georgedias 0313353
multiple fixes - not all working
georgedias 413b2e1
multiple updates
georgedias 1307749
multiple updates
georgedias 5a3a4d9
Fix comment and inline interpolation cases
562d46b
Apply Cookstyle to the expected results
98c4bd5
Apply Cookstyle to control test
7c5c35f
Added documentation to tests functions
georgedias 1daa06c
updates to the control test logic
georgedias 756861d
corrected linting
georgedias b409b04
minor updates - ready to merge
georgedias 6431e9e
allowing tags to have nil values
georgedias 0c76421
corrected logic for properly set impact value
georgedias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,21 +84,85 @@ export default class Control { | |
| return new Control(unflatten(flattened)); | ||
| } | ||
|
|
||
| toRuby() { | ||
| // WIP - provides the ability to get the control in its raw form | ||
| toString() { | ||
|
em-c-rod marked this conversation as resolved.
|
||
| let result = ''; | ||
| result += `control '${this.id}' do\n`; | ||
|
|
||
| if (this.title) { | ||
| result += ` title "${this.title}"\n`; | ||
| } | ||
| // This is the known 'default' description - on previous version this content was repeated on descriptions processed by "descs" | ||
| if (this.desc) { | ||
| result += ` desc "${this.desc}"\n`; | ||
| } | ||
|
|
||
| if (this.descs) { | ||
| Object.entries(this.descs).forEach(([key, subDesc]) => { | ||
| if (subDesc) { | ||
| result += ` desc '${key}', "${subDesc}"\n`; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| if (this.impact) { | ||
| result += ` impact ${this.impact}\n`; | ||
| } | ||
|
|
||
| if (this.refs) { | ||
| this.refs.forEach((ref) => { | ||
| if (typeof ref === 'string') { | ||
| result += ` ref "${ref}"\n`; | ||
| } else { | ||
| result += ` ref ${ref.ref?.toString() || ''}, url: ${ref.url || ''}` | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| Object.entries(this.tags).forEach(([tag, value]) => { | ||
| if (typeof value === 'object') { | ||
| if (Array.isArray(value) && typeof value[0] === 'string') { | ||
| result += ` tag ${tag}: ${JSON.stringify(value)}\n` | ||
| } else { | ||
| result += ` tag '${tag}': ${(value==null?'nil':value)}\n` | ||
| } | ||
| } else if (typeof value === 'string') { | ||
| if (value.includes('"')) { | ||
| result += ` tag "${tag}": "${value}"\n`; | ||
| } else { | ||
| result += ` tag '${tag}': '${value}'\n`; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| if (this.describe) { | ||
| result += '\n'; | ||
| result += this.describe | ||
| } | ||
|
|
||
| if (!result.slice(-1).match('\n')) { | ||
| result += '\n'; | ||
| } | ||
| result += 'end\n'; | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| toRuby(verbose = true) { | ||
| let result = ''; | ||
|
|
||
| result += `control '${this.id}' do\n`; | ||
| if (this.title) { | ||
| result += ` title ${escapeQuotes(this.title)}\n`; | ||
| } else { | ||
| console.error(`${this.id} does not have a title`); | ||
| if (verbose) {console.error(`${this.id} does not have a title`);} | ||
| } | ||
|
|
||
| // This is the known 'default' description - on previous version this content was repeated on descriptions processed by "descs" | ||
| if (this.desc) { | ||
| result += ` desc ${escapeQuotes(this.desc)}\n`; | ||
| } else { | ||
| console.error(`${this.id} does not have a desc`); | ||
| if (verbose) {console.error(`${this.id} does not have a desc`);} | ||
| } | ||
|
|
||
| if (this.descs) { | ||
|
|
@@ -109,22 +173,22 @@ export default class Control { | |
| // The "default" keyword may have the same content as the desc content for backward compatibility with different historical InSpec versions. | ||
| // In that case, we can ignore writing the "default" subdescription field. | ||
| // If they are different, however, someone may be trying to use the keyword "default" for a unique subdescription, which should not be done. | ||
| console.error(`${this.id} has a subdescription called "default" with contents that do not match the main description. "Default" should not be used as a keyword for unique sub-descriptions.`); | ||
| if (verbose) {console.error(`${this.id} has a subdescription called "default" with contents that do not match the main description. "Default" should not be used as a keyword for unique sub-descriptions.`);} | ||
| } | ||
| } | ||
| else { | ||
| result += ` desc '${key}', ${escapeQuotes(subDesc)}\n`; | ||
| } | ||
| } else { | ||
| console.error(`${this.id} does not have a desc for the value ${key}`); | ||
| if (verbose) {console.error(`${this.id} does not have a desc for the value ${key}`);} | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| if (this.impact) { | ||
| result += ` impact ${this.impact}\n`; | ||
| if (this.impact !== undefined) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch |
||
| result += ` impact ${(this.impact<=0?this.impact.toFixed(1):this.impact)}\n` | ||
| } else { | ||
| console.error(`${this.id} does not have an impact`); | ||
| if (verbose) {console.error(`${this.id} does not have an impact`);} | ||
| } | ||
|
|
||
| if (this.refs) { | ||
|
|
@@ -161,6 +225,8 @@ export default class Control { | |
| } else if (typeof value === 'string') { | ||
| result += ` tag ${tag}: ${escapeQuotes(value)}\n`; | ||
| } | ||
| } else { | ||
| result += ` tag ${tag}: nil\n`; | ||
| } | ||
| }); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| control 'SV-205653' do | ||
| title 'Windows Server 2019 reversible password encryption must be disabled.' | ||
| desc 'Storing passwords using reversible encryption is essentially the same as storing clear-text versions of the passwords, which are easily compromised. For this reason, this policy must never be enabled.' | ||
| desc 'check', 'Verify the effective setting in Local Group Policy Editor. | ||
|
|
||
| Run "gpedit.msc". | ||
|
|
||
| Navigate to Local Computer Policy >> Computer Configuration >> Windows Settings >> Security Settings >> Account Policies >> Password Policy. | ||
| If the value for "Store passwords using reversible encryption" is not set to "Disabled", this is a finding. | ||
|
|
||
| For server core installations, run the following command: | ||
| Secedit /Export /Areas SecurityPolicy /CFG C:\\Path\\FileName.Txt | ||
| If "ClearTextPassword" equals "1" in the file, this is a finding.' | ||
| desc 'fix', 'Configure the policy value for Computer Configuration >> Windows Settings >> Security Settings >> Account Policies >> Password Policy >> "Store passwords using reversible encryption" to "Disabled".' | ||
| impact 0.7 | ||
| tag gtitle: 'SRG-OS-000073-GPOS-00041' | ||
| tag gid: 'V-93465' | ||
| tag rid: 'SV-103551r1_rule' | ||
| tag stig_id: 'WN19-AC-000090' | ||
| tag fix_id: 'F-99709r1_fix' | ||
| tag cci: ['CCI-000196'] | ||
| tag nist: ['IA-5 (1) (c)', 'Rev_4'] | ||
|
|
||
| describe security_policy do | ||
| its('ClearTextPassword') { should eq 0 } | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.