{
    "name": "SecurityScorecardFactorCCPDefinition",
    "apiVersion": "2025-07-01-preview",
    "type": "Microsoft.SecurityInsights/dataConnectorDefinitions",
    "location": "{{location}}",
    "kind": "Customizable",
    "properties": {
        "connectorUiConfig": {
            "id": "SecurityScorecardFactorCCPDefinition",
            "title": "SecurityScorecard Factors (via Codeless Connector Framework)",
            "publisher": "SecurityScorecard",
            "descriptionMarkdown": "The SecurityScorecard Factors (via Codeless Connector Framework) connector ingests company factor-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 rows land in `SecurityScorecardFactorHistory_CL`; query via the `SecurityScorecardFactor` parser to get day-over-day deltas with factor metadata, matching the legacy Function App schema.",
            "graphQueriesTableName": "SecurityScorecardFactorHistory_CL",
            "graphQueries": [
                {
                    "metricName": "Total Factor history rows received",
                    "legend": "SecurityScorecard factor history",
                    "baseQuery": "{{graphQueriesTableName}}"
                }
            ],
            "sampleQueries": [
                {
                    "description": "Day-over-day factor change (parser)",
                    "query": "SecurityScorecardFactor\n | sort by TimeGenerated desc"
                },
                {
                    "description": "Raw factor 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, 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 factor-score history for the companies in a single portfolio and is listed, managed, and deleted independently below. To also ingest your own company's factor scores (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
                                                    }
                                                }
                                            }
                                        ]
                                    }
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    }
}
