{
    "name": "SecurityScorecardRatingsCCPDefinition",
    "apiVersion": "2025-07-01-preview",
    "type": "Microsoft.SecurityInsights/dataConnectorDefinitions",
    "location": "{{location}}",
    "kind": "Customizable",
    "properties": {
        "connectorUiConfig": {
            "id": "SecurityScorecardRatingsCCPDefinition",
            "title": "SecurityScorecard Ratings (via Codeless Connector Framework)",
            "publisher": "SecurityScorecard",
            "descriptionMarkdown": "The SecurityScorecard Ratings (via Codeless Connector Framework) connector ingests overall company score history into Microsoft Sentinel. Add one connection per SecurityScorecard portfolio you want to monitor — each connection is managed independently in the grid below. Raw daily score rows land in `SecurityScorecardRatingsHistory_CL`; query via the `SecurityScorecardRatings` parser for day-over-day deltas matching the legacy Function App schema.",
            "graphQueriesTableName": "SecurityScorecardRatingsHistory_CL",
            "graphQueries": [
                {
                    "metricName": "Total Ratings history rows received",
                    "legend": "SecurityScorecard ratings history",
                    "baseQuery": "{{graphQueriesTableName}}"
                }
            ],
            "sampleQueries": [
                {
                    "description": "Day-over-day rating change (parser)",
                    "query": "SecurityScorecardRatings\n | sort by TimeGenerated desc"
                },
                {
                    "description": "Raw ratings history",
                    "query": "{{graphQueriesTableName}}\n | sort by TimeGenerated desc"
                }
            ],
            "dataTypes": [
                {
                    "name": "{{graphQueriesTableName}}",
                    "lastDataReceivedQuery": "{{graphQueriesTableName}}\n | summarize Time = max(TimeGenerated)\n | where isnotempty(Time)"
                }
            ],
            "connectivityCriteria": [
                {
                    "type": "HasDataConnectors"
                }
            ],
            "availability": {
                "isPreview": false
            },
            "permissions": {
                "resourceProvider": [
                    {
                        "provider": "Microsoft.OperationalInsights/workspaces",
                        "permissionsDisplayText": "Read and Write permissions are required.",
                        "providerDisplayName": "Workspace",
                        "scope": "Workspace",
                        "requiredPermissions": {
                            "write": true,
                            "read": true,
                            "delete": true
                        }
                    }
                ],
                "customs": [
                    {
                        "name": "SecurityScorecard API token",
                        "description": "A SecurityScorecard API token is required."
                    }
                ]
            },
            "instructionSteps": [
                {
                    "title": "STEP 1 - Create a SecurityScorecard API token",
                    "description": "As an administrator in SecurityScorecard, navigate to My Settings then Users, create a bot user with Read Only permission, and generate the API token."
                },
                {
                    "title": "STEP 2 - Add a portfolio connection",
                    "description": "Add one connection per SecurityScorecard portfolio. Each connection ingests the overall company scores for a single portfolio and is listed, managed, and deleted independently below. To also ingest your own company's scorecard (My Scorecard), enter your company domain in the optional field on one connection.",
                    "instructions": [
                        {
                            "type": "DataConnectorsGrid",
                            "parameters": {
                                "mapping": [
                                    {
                                        "columnName": "Portfolio Name",
                                        "columnValue": "properties.addOnAttributes.portfolio_name"
                                    },
                                    {
                                        "columnName": "Portfolio ID",
                                        "columnValue": "properties.addOnAttributes.portfolio_id"
                                    }
                                ],
                                "menuItems": [
                                    "DeleteConnector"
                                ]
                            }
                        },
                        {
                            "type": "ContextPane",
                            "parameters": {
                                "label": "Add portfolio",
                                "title": "Add a SecurityScorecard portfolio",
                                "subtitle": "Connect one SecurityScorecard portfolio",
                                "contextPaneType": "DataConnectorsContextPane",
                                "instructionSteps": [
                                    {
                                        "instructions": [
                                            {
                                                "type": "Textbox",
                                                "parameters": {
                                                    "label": "Base URL",
                                                    "placeholder": "https://api.securityscorecard.io",
                                                    "type": "text",
                                                    "name": "BaseUrl",
                                                    "validations": {
                                                        "required": true
                                                    }
                                                }
                                            },
                                            {
                                                "type": "Textbox",
                                                "parameters": {
                                                    "label": "API Token",
                                                    "placeholder": "Enter your SecurityScorecard API token",
                                                    "type": "password",
                                                    "name": "ApiToken",
                                                    "validations": {
                                                        "required": true
                                                    }
                                                }
                                            },
                                            {
                                                "type": "Textbox",
                                                "parameters": {
                                                    "label": "Portfolio ID",
                                                    "placeholder": "Enter the SecurityScorecard portfolio ID",
                                                    "type": "text",
                                                    "name": "PortfolioId",
                                                    "validations": {
                                                        "required": true
                                                    }
                                                }
                                            },
                                            {
                                                "type": "Textbox",
                                                "parameters": {
                                                    "label": "Portfolio Name",
                                                    "placeholder": "A friendly name for this portfolio (shown in reports and the workbook)",
                                                    "type": "text",
                                                    "name": "PortfolioName",
                                                    "validations": {
                                                        "required": true
                                                    }
                                                }
                                            },
                                            {
                                                "type": "Textbox",
                                                "parameters": {
                                                    "label": "Your Company Domain (optional - My Scorecard)",
                                                    "placeholder": "e.g. yourcompany.com - leave blank if not needed",
                                                    "type": "text",
                                                    "name": "Domain",
                                                    "validations": {
                                                        "required": false
                                                    }
                                                }
                                            }
                                        ]
                                    }
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    }
}
