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

Convert Microsoft Secure Score to OHDF #6007

Merged
merged 79 commits into from
Aug 7, 2024
Merged

Convert Microsoft Secure Score to OHDF #6007

merged 79 commits into from
Aug 7, 2024

Conversation

meme112233
Copy link
Contributor

@meme112233 meme112233 commented Jul 18, 2024

This PR introduces the converter for Microsoft SecureScore to OHDF.

Mapping is performed using the output of two Microsoft Graph API endpoints:

The mapper takes the output of the two endpoints as a single json document. Each document is included as an object under the keys profiles and secureScore.

{
   "secureScore":  <The full text of the secureScore endpoint output as JSON object>,
   "profiles":  <The full text of the secureScoreControlProfiles endpoint output as JSON object>
}

This combined file can be built with jq

jq -s '{"secureScore": .[0], "profiles": .[1]}' secureScore.json profiles.json

Sample combined secureScore/profiles document for testing:
combined_msft.json

Mapper design decisions of interest

  • impact: Derived from the maxScore of the Profile matching the controlName
    • When no matching Profile is found, a default impact of 0.5 is used
  • status:
    • success:
      • scoreInPercentage === 100
      • score === max value from maxScore field of any matching Profile
    • error:
      • score field is undefined (per API, should never happen)
    • fail:
      • any other condition
  • tags
    • groups
      • controlCategory field from any matching Profiles
    • threats
      • threat field from any matching Profiles

A matching PR for the SAF-CLI is expected early next week that will support:

  • CLI conversion of combined secureScore endpoints to OHDF.
    • Starting with pre-downloaded REST endpoint outputs
    • Starting from Graph API credentials

@ejaronne
Copy link
Contributor

  1. Profiles.value.title: recommend for controls.title
  2. Perhaps the Impact should be based on Profiles.value.userImpact instead of Profiles.value.maxScore? I can't yet find the Microsoft documentation that explains the difference between these. Impact is intended to be the relative danger should this control be in a failed state.
  3. Remediation: seems like a perfect opportunity as descriptions:[data:””, label:”fix”]
  4. RemediationImpact: seems like a perfect opportunity as descriptions:[data:””, label:”rationale”]

Copy link
Contributor

@charleshu-8 charleshu-8 left a comment

Choose a reason for hiding this comment

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

Part 1 of review, will look at mapper proper later.

libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
combined_msft.json Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
libs/hdf-converters/src/msft-secure-score-mapper.ts Outdated Show resolved Hide resolved
@Amndeep7 Amndeep7 added the ready-to-merge Used by mergify to identify if a PR is ready to merge into master. label Aug 7, 2024
@Amndeep7 Amndeep7 merged commit f5c9fe4 into master Aug 7, 2024
8 of 9 checks passed
@Amndeep7 Amndeep7 deleted the meme-working branch August 7, 2024 01:30
Copy link

sonarqubecloud bot commented Aug 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 New Code Smells (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

aaronlippold pushed a commit that referenced this pull request Nov 20, 2024
* draft of the microsoftSecureScore converter

* bugfix: reading of secureScoreProfiles doc needed field for the array

* minor update map/filter

* add threats to tags from profile matching controlScore

* add testing and update status check to use scoreInPercentage

* update testing and fingerprinting

* update fingerprinting for accept combined msftSecureScore document via UX

* lint fix

* msft-config-mapper-2.ts renamed without 2, cleanup commented out code

* code cleanup. delete unused code

* tslint allow commented out code in test suite

* revert jest version bump

* revert package.json to minimal requirements being added (only typing from MSFT)

* rename mapper for consistency. msft_secure_score_mapper

* update test name and remove linting inline disble block for commented out code

* rename files for org per PR comments

* update tags. fix array of array issue. add tiers,services,userImpact tags, add passthrough partial wroking

* bugfix: replace missed exports due to rename to MsftSecureScoreMapper

* bugfix/ typo

* console debugging

* Revert "console debugging"

This reverts commit 8a003c8.

* Passthrough fix; minor styling changes

Signed-off-by: Charles Hu <[email protected]>

* actual sample msft secureScore.json test doc updated to have value: []

* bugfix/populate code with control data and optionally profiles data

* Update libs/hdf-converters/src/msft-secure-score-mapper.ts

Co-authored-by: Charles Hu <[email protected]>

* remove 'summary' field as no value available

* Update libs/hdf-converters/src/msft-secure-score-mapper.ts

Co-authored-by: Charles Hu <[email protected]>

* improve names of parameters in arrow functions

* Update libs/hdf-converters/src/msft-secure-score-mapper.ts

Co-authored-by: Charles Hu <[email protected]>

* remove unuded profile.version field as no value known from Microsoft

* code cleanup. remove unused import

* lint and update test expected results

* update test data

* Missed argument name change

Signed-off-by: Charles Hu <[email protected]>

* Linting

Signed-off-by: Charles Hu <[email protected]>

* implementationStatus -> controls.results.code_desc, remediation -> descriptions. data/label fix
, leave controls.code blank

* update test data for changes to mapper

* Update msft-secure-score-mapper.ts

* lint fix and update test data

* relocate NIST to be in tags

* sort exports per PR comment

* add Msft_Secure_mapper to supported formats README.md

* typo fixed

* add run_time to mapper. required for downstream transformations that require start and end times.

* update delimeter on control title from ... to \n

* rename tag: group->category in dederence to msft naming

* utilize lodash.uniq for tag.threats[]

* add profiles[].remediationImpact as descriptions[label:rationale]

* add secure score to FileReader.vue

* update merge of records by id/cat

* fix rawdata passthrough

* update profiles.title include runID

* handle output readability better

* track secureScoreControlProfile.rank as control.tag.rank

* remove run_time

* cleanup inports

* lint fix

* conditional includsion of tags

* secureScoreResults used to output full OHDF report per secureScore report in combined_input

* bugfix/ exports from msft-secure-score-mapper fixed

* update exports msftSecureMapper

* export MsftSecureScoreMapper

* add unmapped fields as tags or passthrough data

* update MsftSecureScoreResult type hints

* update MsftSecureScoreResult type hints

* add withRaw parameter to msft secure score results

* use utils.global constants for default NIST tags

* remove duplicate tag 'rank'

* convert forEach to for ... of

* convert forEach to map(..)

* delete extra copy of combined_msft.json

* lint fix

* private keyword isn't that useful

Signed-off-by: Amndeep Singh Mann <[email protected]>

* memoized the getProfiles function so that the repeated calls to the function don't all need to do the search

Signed-off-by: Amndeep Singh Mann <[email protected]>

---------

Signed-off-by: Charles Hu <[email protected]>
Signed-off-by: Amndeep Singh Mann <[email protected]>
Co-authored-by: Charles Hu <[email protected]>
Co-authored-by: Charles Hu <[email protected]>
Co-authored-by: Eugene Aronne <[email protected]>
Co-authored-by: Amndeep Singh Mann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hdf-converters Issue related to the HDF Converters library ready-to-merge Used by mergify to identify if a PR is ready to merge into master.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants