Skip to content

Commit

Permalink
Update License to Elastic v2 (elastic#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
brokensound77 authored Mar 4, 2021
1 parent 8c4df09 commit 3fc34b8
Show file tree
Hide file tree
Showing 692 changed files with 1,697 additions and 1,645 deletions.
316 changes: 93 additions & 223 deletions LICENSE.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ We welcome your contributions to Detection Rules! Before contributing, please fa

## Licensing

Everything in this repository — rules, code, RTA, etc. — is licensed under the [Elastic License](LICENSE.txt). These rules are designed to be used in the context of the Detection Engine within the Elastic Security application. If you’re using our [Elastic Cloud managed service](https://www.elastic.co/cloud/) or the default distribution of the Elastic Stack software that includes the [full set of free features](https://www.elastic.co/subscriptions), you’ll get the latest rules the first time you navigate to the detection engine.
Everything in this repository — rules, code, RTA, etc. — is licensed under the [Elastic License v2](LICENSE.txt). These rules are designed to be used in the context of the Detection Engine within the Elastic Security application. If you’re using our [Elastic Cloud managed service](https://www.elastic.co/cloud/) or the default distribution of the Elastic Stack software that includes the [full set of free features](https://www.elastic.co/subscriptions), you’ll get the latest rules the first time you navigate to the detection engine.

Occasionally, we may want to import rules from another repository that already have a license, such as MIT or Apache 2.0. This is welcome, as long as the license permits sublicensing under the Elastic License. We keep those license notices in `NOTICE.txt` and sublicense as the Elastic License with all other rules. We also require contributors to sign a [Contributor License Agreement](https://www.elastic.co/contributor-agreement) before contributing code to any Elastic repositories.
Occasionally, we may want to import rules from another repository that already have a license, such as MIT or Apache 2.0. This is welcome, as long as the license permits sublicensing under the Elastic License v2. We keep those license notices in `NOTICE.txt` and sublicense as the Elastic License v2 with all other rules. We also require contributors to sign a [Contributor License Agreement](https://www.elastic.co/contributor-agreement) before contributing code to any Elastic repositories.

## Questions? Problems? Suggestions?

Expand Down
5 changes: 3 additions & 2 deletions detection_rules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Detection rules."""
from . import devtools
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

# coding=utf-8
"""Shell for detection-rules."""
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/attack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Mitre attack info."""
import os
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/beats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""ECS Schemas management."""
import os
Expand Down
35 changes: 18 additions & 17 deletions detection_rules/devtools.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""CLI commands for internal detection_rules dev team."""
import glob
import hashlib
import io
import json
Expand Down Expand Up @@ -191,31 +191,32 @@ def git(*args, show_output=False):


@dev_group.command('license-check')
@click.option('--ignore-directory', '-i', multiple=True, help='Directories to skip (relative to base)')
@click.pass_context
def license_check(ctx):
def license_check(ctx, ignore_directory):
"""Check that all code files contain a valid license."""

ignore_directory += ("env",)
failed = False
base_path = Path(get_path())

for path in glob.glob(get_path("**", "*.py"), recursive=True):
if path.startswith(get_path("env", "")):
for path in base_path.rglob('*.py'):
relative_path = path.relative_to(base_path)
if relative_path.parts[0] in ignore_directory:
continue

relative_path = os.path.relpath(path)

with io.open(path, "rt", encoding="utf-8") as f:
contents = f.read()

# skip over shebang lines
if contents.startswith("#!/"):
_, _, contents = contents.partition("\n")
# skip over shebang lines
if contents.startswith("#!/"):
_, _, contents = contents.partition("\n")

if not contents.lstrip("\r\n").startswith(PYTHON_LICENSE):
if not failed:
click.echo("Missing license headers for:", err=True)
if not contents.lstrip("\r\n").startswith(PYTHON_LICENSE):
if not failed:
click.echo("Missing license headers for:", err=True)

failed = True
click.echo(relative_path, err=True)
failed = True
click.echo(relative_path, err=True)

ctx.exit(int(failed))

Expand Down
5 changes: 3 additions & 2 deletions detection_rules/docs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Create summary documents for a rule package."""
from collections import defaultdict
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/ecs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""ECS Schemas management."""
import copy
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/eswrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Elasticsearch cli commands."""
import json
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/kbwrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Kibana cli commands."""
import click
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""CLI commands for detection_rules."""
import glob
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/mappings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""RTA to rule mappings."""
import os
Expand Down
10 changes: 6 additions & 4 deletions detection_rules/misc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Misc support."""
import hashlib
Expand Down Expand Up @@ -42,8 +43,9 @@

LICENSE_HEADER = """
Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
or more contributor license agreements. Licensed under the Elastic License;
you may not use this file except in compliance with the Elastic License.
or more contributor license agreements. Licensed under the Elastic License
2.0; you may not use this file except in compliance with the Elastic License
2.0.
""".strip()

LICENSE_LINES = LICENSE_HEADER.splitlines()
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/packaging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Packaging and preparation for releases."""
import base64
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/rule.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
"""Rule object."""
import base64
import copy
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/rule_formatter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Helper functions for managing rules in the repository."""
import copy
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/rule_loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Load rule metadata transform between rule and api formats."""
import functools
Expand Down
7 changes: 5 additions & 2 deletions detection_rules/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

from .base import TomlMetadata
from .rta_schema import validate_rta_mapping
Expand All @@ -11,6 +12,7 @@
from .v7_9 import ApiSchema79
from .v7_10 import ApiSchema710
from .v7_11 import ApiSchema711
from .v7_12 import ApiSchema712

__all__ = (
"all_schemas",
Expand All @@ -26,6 +28,7 @@
ApiSchema79,
ApiSchema710,
ApiSchema711,
ApiSchema712,
]
CurrentSchema = all_schemas[-1]
available_versions = [cls.STACK_VERSION for cls in all_schemas]
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/schemas/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Definitions for rule metadata and schemas."""

Expand Down
5 changes: 3 additions & 2 deletions detection_rules/schemas/rta_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

import jsl
import jsonschema
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/schemas/v7_10.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Definitions for rule metadata and schemas."""

Expand Down
5 changes: 3 additions & 2 deletions detection_rules/schemas/v7_11.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Definitions for rule metadata and schemas."""

Expand Down
14 changes: 14 additions & 0 deletions detection_rules/schemas/v7_12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Definitions for rule metadata and schemas."""

from .v7_11 import ApiSchema711


class ApiSchema712(ApiSchema711):
"""Schema for siem rule in API format."""

STACK_VERSION = "7.12"
5 changes: 3 additions & 2 deletions detection_rules/schemas/v7_8.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Definitions for rule metadata and schemas."""

Expand Down
7 changes: 4 additions & 3 deletions detection_rules/schemas/v7_9.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Definitions for rule metadata and schemas."""

Expand Down Expand Up @@ -50,7 +51,7 @@ class ApiSchema79(ApiSchema78):
author = jsl.ArrayField(jsl.StringField(default="Elastic"), required=True, min_items=1)
building_block_type = jsl.StringField(required=False)
exceptions_list = jsl.ArrayField(required=False)
license = jsl.StringField(required=True, default="Elastic License")
license = jsl.StringField(required=True, default="Elastic License v2")
risk_score_mapping = jsl.ArrayField(jsl.DocumentField(RiskScoreMapping), required=False, min_items=1)
rule_name_override = jsl.StringField(required=False)
severity_mapping = jsl.ArrayField(jsl.DocumentField(SeverityMapping), required=False, min_items=1)
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/semver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Helper functionality for comparing semantic versions."""
import re
Expand Down
5 changes: 3 additions & 2 deletions detection_rules/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Util functions."""
import contextlib
Expand Down
5 changes: 3 additions & 2 deletions kibana/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Wrapper around Kibana APIs for the Security Application."""

Expand Down
5 changes: 3 additions & 2 deletions kibana/connector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

"""Wrapper around requests.Session for HTTP requests to Kibana."""
import json
Expand Down
5 changes: 3 additions & 2 deletions kibana/resources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

import datetime
from typing import List, Type
Expand Down
Loading

0 comments on commit 3fc34b8

Please sign in to comment.