Ejemplo n.º 1
0
    def test_create_tab_with_locked_ui(self, _get_opts, get_client):
        # these are a mock of app.config
        _get_opts.return_value = {
            "resilient": {
                "ui_lock": "True"
            },
            MockTab.SECTION: {
            }
        }
        # this mocks the requests made to /types and /layout?type_id=xxx
        get_client.return_value.get.side_effect = [
            {
                "organization": {
                    "type_id": 42
                }
            },
            [{
                "id": 42,
                "name": "incident",
                "content": []
            }]
        ]

        create_tab(MockTab)

        # assert that PUT was called and correct payload present
        assert get_client.return_value.put.call_count == 0
Ejemplo n.º 2
0
    def test_create_tab(self, _get_opts, get_client):
        # these are a mock of app.config
        _get_opts.return_value = {
            MockTab.SECTION: {
            }
        }
        # this mocks the requests made to /types and /layout?type_id=xxx
        get_client.return_value.get.side_effect = [
            {
                "organization": {
                    "type_id": 42
                }
            },
            [{
                "id": 42,
                "name": "incident",
                "content": []
            }]
        ]

        create_tab(MockTab)

        # assert that PUT was called and correct payload present
        get_client.return_value.put.assert_called_once()
        call_args = get_client.return_value.put.call_args
        payload = call_args.kwargs.get("payload")
        assert MockTab.exists_in(payload.get('content'))
        for field in MockTab.CONTAINS:
            assert field.exists_in(MockTab.get_from_tabs(payload.get('content')).get("fields"))
Ejemplo n.º 3
0
    def test_conditions_sent(self, _get_opts, get_client):
        # these are a mock of app.config
        _get_opts.return_value = {
            MockTab.SECTION: {
            }
        }
        # this mocks the requests made to /types and /layout?type_id=xxx
        get_client.return_value.get.side_effect = [
            {
                "organization": {
                    "type_id": 42
                }
            },
            [{
                "id": 42,
                "name": "incident",
                "content": [{
                    "predefined_uuid": MockTab.UUID,
                    "fields": [
                        Field("test").as_dto()
                    ]
                }]
            }]
        ]

        create_tab(MockTab, update_existing=True)

        get_client.return_value.put.assert_called_once()
        call_args = get_client.return_value.put.call_args
        payload = call_args.kwargs.get("payload")
        assert MockTab.exists_in(payload.get('content'))
        for field in MockTab.CONTAINS:
            assert field.exists_in(MockTab.get_from_tabs(
                payload.get('content')).get("fields"))
        assert MockTab.get_from_tabs(payload.get('content')).get('show_if') == MockTab.SHOW_IF
Ejemplo n.º 4
0
    NAME = "QRadar Offense Details"

    UUID = "d1ca8936-897b-4a83-8225-01c58db0470b"
    CONTAINS = [
        Field("qradar_id"),
        Field("qr_offense_index_type"),
        Field("qr_offense_index_value"),
        Field("qr_offense_source"),
        Field("qr_source_ip_count"),
        Field("qr_destination_ip_count"),
        Field("qr_event_count"),
        Field("qr_flow_count"),
        Field("qr_assigned"),
        Field("qr_magnitude"),
        Field("qr_credibility"),
        Field("qr_relevance"),
        Field("qr_severity"),
        Datatable("qr_offense_top_events"),
        Datatable("qr_flows"),
        Datatable("qr_triggered_rules"),
        Datatable("qr_top_destination_ips"),
        Datatable("qr_top_source_ips"),
        Datatable("qr_categories"),
        Datatable("qr_assets")
    ]

    SHOW_IF = [Field("qradar_id").conditions.has_value()]


create_tab(QRadarTab, update_existing=True)
    NAME = "QRadar Offense Details"

    UUID = "d1ca8936-897b-4a83-8225-01c58db0470b"
    CONTAINS = [
        Field("qradar_id"),
        Field("qr_offense_index_type"),
        Field("qr_offense_index_value"),
        Field("qr_offense_source"),
        Field("qr_source_ip_count"),
        Field("qr_destination_ip_count"),
        Field("qr_event_count"),
        Field("qr_flow_count"),
        Field("qr_assigned"),
        Field("qr_magnitude"),
        Field("qr_credibility"),
        Field("qr_relevance"),
        Field("qr_severity"),
        Datatable("qr_offense_top_events"),
        Datatable("qr_flows"),
        Datatable("qr_triggered_rules"),
        Datatable("qr_top_destination_ips"),
        Datatable("qr_top_source_ips"),
        Datatable("qr_categories"),
        Datatable("qr_assets")
    ]

    SHOW_IF = [Field("qradar_id").conditions.has_value()]


create_tab(QRadarTab, AppArgumentParser().parse_args(), update_existing=True)