def rule(event):
    if all(
        [
            any(
                [
                    event.deep_get("Image", default="").endswith("/service"),
                    event.deep_get("Image", default="").endswith("/systemctl"),
                    event.deep_get("Image", default="").endswith("/chkconfig"),
                ]
            ),
            any(
                [
                    " stop " in event.deep_get("CommandLine", default=""),
                    " disable " in event.deep_get("CommandLine", default=""),
                ]
            ),
            not any(
                [
                    all(
                        [
                            event.deep_get("Image", default="").endswith("/systemctl"),
                            any(
                                [
                                    "--no-reload disable snap-snapd-"
                                    in event.deep_get("CommandLine", default=""),
                                    " stop snap-snapd-"
                                    in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("Image", default="").endswith("/systemctl"),
                            "tmp.ci/preinst upgrade"
                            in event.deep_get("ParentCommandLine", default=""),
                            " stop " in event.deep_get("CommandLine", default=""),
                            "ssh." in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    all(
                        [
                            "/dpkg/info/ubuntu-pro-client.prerm upgrade"
                            in event.deep_get("ParentCommandLine", default=""),
                            event.deep_get("Image", default="").endswith("/systemctl"),
                        ]
                    ),
                ]
            ),
            not all(
                [
                    event.deep_get("Image", default="").endswith("/systemctl"),
                    event.deep_get("CommandLine", default="").endswith(
                        "snap.amazon-ssm-agent.amazon-ssm-agent.service"
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
