How to calculate the identity/apps/device/data security scores from the data obtained from the Graph api query?

Annie Thomas Kanaparthi 0 Reputation points
2024-04-26T07:40:37.2766667+00:00

Can we calculate the identity , apps, data & device scores from this data that we obtain from the secure score query using graph api?

"averageComparativeScores": [

    {

      "basis": "AllTenants",

      "averageScore": 53.65,

      "appsScore": 30.19,

      "appsScoreMax": 81.25,

      "dataScore": 0.47,

      "dataScoreMax": 3.38,

      "deviceScore": 9.04,

      "deviceScoreMax": 16.57,

      "identityScore": 35.27,

      "identityScoreMax": 59.54,

      "infrastructureScore": 0,

      "infrastructureScoreMax": 0

    },

    {

      "basis": "TotalSeats",

      "averageScore": 42.03,

      "SeatSizeRangeLowerValue": "1001",

      "SeatSizeRangeUpperValue": "10000",

      "appsScore": 78.66,

      "appsScoreMax": 187.95,

      "dataScore": 1.97,

      "dataScoreMax": 6.79,

      "deviceScore": 96.26,

      "deviceScoreMax": 172.91,

      "identityScore": 32.03,

      "identityScoreMax": 71.01,

      "infrastructureScore": 0,

      "infrastructureScoreMax": 0

    }
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,978 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hashem Barakat 0 Reputation points
    2024-07-03T12:22:19.04+00:00

    Using Logic Apps and the Microsoft Graph API, I was able to calculate security scores for various categories like Apps and Identity. Here's a concise explanation of the process:

    1. API Used:
    2. Process:
      • Use a "For Each" loop to iterate through each category.
      • Inside the loop, filter the array to process each category individually (e.g., Apps, Identity, etc.).
      • Initialize MaxScore and Score variables to 0.
    3. Score Calculation:
      • Add another loop inside the category loop to iterate through all controls for that category.
      • Use a compose action with the following equation to calculate MaxScore:
             if(
                 equals(mul(float(items('For_each_6')?['scoreInPercentage']), 0.01), 0),
                 1,
                 div(
                     items('For_each_6')?['score'],
                     mul(float(items('For_each_6')?['scoreInPercentage']), 0.01)
                 )
             )
        
        This expression checks if scoreInPercentage is 0 to avoid division by zero. If it is, it sets MaxScore to 1. Otherwise, it calculates MaxScore by dividing Score by the percentage converted to a decimal.
    4. Handling Zero Scores:
      • Sometimes Score and scoreInPercentage are 0 even if there is a MaxScore.
      • To handle this, use an HTTP request before the second loop with this API:
      • [Microsoft Graph API for Control Profiles] to retrieve MaxScore.
      • Create a condition: if Score is 0, retrieve MaxScore using the API; otherwise, use the calculated value.
    5. Summing Scores:
      • Sum all Score values and MaxScore values for each control in the category.
      • Divide the total Score by the total MaxScore to get the percentage for that control category.
    6. Some Screenshots of the Logic App to help understand 1. Categories of Secure Score
      User's image
      1. HTTP Request User's image
      2. first for each loop that loops through categories
        User's image
      3. Second Loop inside first loop
        User's image Let me know if you need help figuring out anything.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.