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 report module to handle italics and multiline processing in policy description #730

Merged
merged 30 commits into from
Jan 25, 2024

Conversation

isab-m
Copy link
Contributor

@isab-m isab-m commented Dec 11, 2023

🗣 Description

HTML reporting shows Markdown notation and extra line breaks. Markdown notation is not rendered and is shown as is which can make the requirement text harder to interpret or at the very least is less visually appealing. Fixes the HTML reporting translation of italic and bold notation from the baseline's policy description markdown notation. Fixes extra line breaks and list breaks in html reports.

💭 Motivation and context

  • Added the HTML translation of italics notation from the baseline's policy description markdown
  • Added the HTML translation of bold notation from the baseline's policy description markdown
  • Fixes extra line breaks and list breaks in reports

Closes #604

🧪 Testing

  • Testing italics markdown-to-html translation
  1. Edit a baseline doc policy descriptions by adding "_" italics notation to beginning and end of a policy description line
  2. Import-Module -Name .\PowerShell\ScubaGear
  3. Invoke-SCuBA -ProductNames aad, defender
  • Testing bold markdown-to-html translation
  1. Edit a baseline doc policy descriptions by adding "**" bold notation to beginning and end of a policy description line
  2. Import-Module -Name .\PowerShell\ScubaGear
  3. Invoke-SCuBA -ProductNames aad
  • Testing both bold and italics markdown-to-html translation
  1. Edit a baseline doc policy descriptions by adding "_" italics notation to beginning and end of a policy description line and bold "**"
  2. Import-Module -Name .\PowerShell\ScubaGear
  3. Invoke-SCuBA -ProductNames aad

📷 Screenshots (if appropriate)

image
image
Italics notation added to baseline using "_"

image
image
Italics notation rendered correctly in report descriptions

image

Bold notation added to baseline policy description MS.AAD.2.3v1 using "**"

image

Bold notation translation rendered correctly in report descriptions

image

Bold notation added to baseline policy description MS.AAD.2.3v1 using "**" with italics "_" notation added inside

image

Bold and Italics notation rendered correctly in report descriptions

image

Italics notation added to baseline policy description MS.AAD.2.2v1 using "_" with bold "**" notation added inside

image Italics and bold notation rendered correctly in report descriptions

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced
    in code comments.
  • All relevant type-of-change labels have been added.
  • All relevant repo and/or project documentation has been updated
    to reflect the changes in this PR.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.

✅ Pre-merge checklist

  • Feature branch has been rebased with latest changes from main
  • Notified merge coordinator issue is ready for merge

✅ Post-merge checklist

  • Verify all tests are passing on main branch after merge

@isab-m isab-m added the bug This issue or pull request addresses broken functionality label Dec 11, 2023
@isab-m isab-m added this to the Flipper - Dec 2023 milestone Dec 11, 2023
@isab-m isab-m self-assigned this Dec 11, 2023
@isab-m isab-m changed the base branch from flipper to main December 11, 2023 18:57
@isab-m isab-m changed the base branch from main to flipper December 11, 2023 18:57
@schrolla
Copy link
Collaborator

@isab-m Please update the PR title from the default to a clearer title. Preferably starting with a present tense verb and a short description that explains the purpose of the update. The PR title becomes the merge commit message that lives on in the commit history on the main branch, so title is important as it communicates the actual change to users.

@schrolla
Copy link
Collaborator

The italics fix is good, but this PR does not close #604 entirely as it does not address extra line breaks in policy statements rendered in the report. Either split #604 so that a new issue to address line breaks is created outside the scope of this PR or update the PR to address the extra line breaks issue as well.

Copy link
Contributor

@crutchfield crutchfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a unit test to verify proper transformation.

@isab-m
Copy link
Contributor Author

isab-m commented Dec 13, 2023

The italics fix is good, but this PR does not close #604 entirely as it does not address extra line breaks in policy statements rendered in the report. Either split #604 so that a new issue to address line breaks is created outside the scope of this PR or update the PR to address the extra line breaks issue as well.

@schrolla
Originally thought this was fixed with #528 but realized it looked correct in the report for certain multiline cases like MS.EXO.16.1v1
image
but cases like MS.TEAMS.6.2v1 still showed newline breaks in report
image

Updated code to reflect multiline processing split into two use cases shown below:

Multiline Use Case
Multiline case processing utilizing " ". fixes the cases where report renders new lines MS.TEAMS.6.2v1
image

Visually, can't see much of a difference in this multiline case being present here in MS.DEFENDER.4.6v1
image

However, upon further investigation into raw text in defender baseline doc, a newline is present in the policy description
image

Multiline case resolves this newline break in markdown, which visually can be shown using a diff tool on the text.
image

List Use Cases
List case processing utilizing "`n". lists rendered correctly in report MS.EXO.16.1v1
image

@isab-m isab-m changed the title 604 html report markdown cleanup Update report module to handle italics and multiline processing in policy description Dec 13, 2023
Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments below for recommended updates.

Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran full Invoke-Scuba -p * and reviewed output of all reports. Updated rendering looks much better, especially MS.EXO.16.1 with correct multi-line breaks and properly rendered bolded sub-items. All unit tests ran successfully as well. Great work!

Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor oversight on my part. The baselines were changed, I'm assuming for testing. I'd recommend reverting/removing those changes so we aren't modifying the baselines for this code update.

Copy link
Contributor

@crutchfield crutchfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. An earlier comment as to consider adding/enhancing unit test to check that this capability works (and does not get broke in the future) -- Tests have been added and/or modified to cover the changes in this PR.
  2. Please fix identified linter errors in CreateReport.psm1
  3. Need to rebase

@schrolla schrolla changed the base branch from flipper to main January 19, 2024 14:58
@isab-m isab-m linked an issue Jan 22, 2024 that may be closed by this pull request
@isab-m isab-m reopened this Jan 22, 2024
@isab-m
Copy link
Contributor Author

isab-m commented Jan 22, 2024

  1. An earlier comment as to consider adding/enhancing unit test to check that this capability works (and does not get broke in the future) -- Tests have been added and/or modified to cover the changes in this PR.
  2. Please fix identified linter errors in CreateReport.psm1
  3. Need to rebase

All 3 items added to code. Can I get a review on my unit tests @crutchfield?

Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran again successfully, showing correct multiline, italics, and bold processing. Ran PS and rego unit tests successfully. New unit tests for translation function adequately test for bad input and output values and test valid translations. Looks good to me.

@crutchfield crutchfield self-requested a review January 23, 2024 14:38
Copy link
Contributor

@crutchfield crutchfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are a couple comments to look at.

Copy link
Contributor

@crutchfield crutchfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses immediate needs. Future enhancement will be addressed by #847

@schrolla schrolla changed the title Update report module to handle italics and multiline processing in policy description Fix report module to handle italics and multiline processing in policy description Jan 25, 2024
@schrolla
Copy link
Collaborator

@nanda-katikaneni PR is ready for merge.

@nanda-katikaneni nanda-katikaneni merged commit f9d8241 into main Jan 25, 2024
6 checks passed
@nanda-katikaneni nanda-katikaneni deleted the 604-html-report-markdown-cleanup branch January 25, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue or pull request addresses broken functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTML reporting shows Markdown notation and extra line breaks
4 participants