diffguard-ai 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. diffguard/__init__.py +39 -0
  2. diffguard/__main__.py +4 -0
  3. diffguard/baselines/__init__.py +0 -0
  4. diffguard/baselines/manager.py +97 -0
  5. diffguard/cli/__init__.py +1 -0
  6. diffguard/cli/main.py +323 -0
  7. diffguard/core/__init__.py +0 -0
  8. diffguard/core/enums.py +103 -0
  9. diffguard/core/exceptions.py +57 -0
  10. diffguard/core/interfaces.py +20 -0
  11. diffguard/core/models.py +301 -0
  12. diffguard/engine/__init__.py +0 -0
  13. diffguard/engine/evaluator.py +42 -0
  14. diffguard/engine/orchestrator.py +74 -0
  15. diffguard/engine/registry.py +142 -0
  16. diffguard/engine/scanner.py +141 -0
  17. diffguard/git/__init__.py +0 -0
  18. diffguard/git/client.py +179 -0
  19. diffguard/git/diff_parser.py +298 -0
  20. diffguard/git/repository.py +174 -0
  21. diffguard/policies/__init__.py +0 -0
  22. diffguard/policies/loader.py +75 -0
  23. diffguard/policies/schema.py +292 -0
  24. diffguard/py.typed +0 -0
  25. diffguard/reporting/__init__.py +0 -0
  26. diffguard/reporting/json_report.py +104 -0
  27. diffguard/reporting/markdown_report.py +96 -0
  28. diffguard/reporting/text_report.py +43 -0
  29. diffguard/rules/__init__.py +0 -0
  30. diffguard/rules/base.py +248 -0
  31. diffguard/rules/configuration.py +98 -0
  32. diffguard/rules/dangerous_patterns.py +290 -0
  33. diffguard/rules/dependencies.py +375 -0
  34. diffguard/rules/filetypes.py +49 -0
  35. diffguard/rules/scope.py +108 -0
  36. diffguard/rules/secret_patterns.py +195 -0
  37. diffguard/rules/secrets.py +118 -0
  38. diffguard/rules/test_removal.py +253 -0
  39. diffguard/suppressions/__init__.py +0 -0
  40. diffguard/suppressions/manager.py +81 -0
  41. diffguard/utils/__init__.py +0 -0
  42. diffguard/utils/logging.py +23 -0
  43. diffguard/utils/paths.py +131 -0
  44. diffguard/version.py +1 -0
  45. diffguard_ai-0.1.0.dist-info/METADATA +141 -0
  46. diffguard_ai-0.1.0.dist-info/RECORD +49 -0
  47. diffguard_ai-0.1.0.dist-info/WHEEL +4 -0
  48. diffguard_ai-0.1.0.dist-info/entry_points.txt +2 -0
  49. diffguard_ai-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,131 @@
1
+ """Path normalization, glob matching and repository-safe file access.
2
+
3
+ Glob semantics (identical on every platform, always case-sensitive):
4
+
5
+ * Patterns are relative to the repository root and use ``/`` separators.
6
+ Backslashes are converted to ``/``; escaping is not supported.
7
+ * ``*`` matches any characters except ``/``; ``?`` matches one non-``/`` character;
8
+ ``[abc]`` / ``[!abc]`` are character classes.
9
+ * ``**`` must be a whole path segment. It matches zero or more directories in the
10
+ middle of a pattern (``a/**/b``) and one or more path components at the end
11
+ (``src/**`` matches everything below ``src/`` but not ``src`` itself).
12
+ * A pattern without ``/`` only matches at the repository root. Use ``**/name`` to
13
+ match at any depth.
14
+ * Absolute paths, ``..`` segments, negation (``!``) and trailing ``/`` are rejected
15
+ rather than interpreted, so a pattern never has two plausible meanings.
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import re
21
+ from collections.abc import Iterable
22
+ from functools import lru_cache
23
+ from pathlib import Path
24
+
25
+ from diffguard.core.exceptions import PathSafetyError, PatternError
26
+
27
+
28
+ def normalize_pattern(pattern: object) -> str:
29
+ if not isinstance(pattern, str) or not pattern.strip():
30
+ raise PatternError("pattern must be a non-empty string")
31
+ p = pattern.strip().replace("\\", "/")
32
+ while p.startswith("./"):
33
+ p = p[2:]
34
+ if p.startswith("!"):
35
+ raise PatternError(f"{pattern!r}: negated patterns are not supported")
36
+ if p.startswith("/") or re.match(r"^[A-Za-z]:", p):
37
+ raise PatternError(f"{pattern!r}: patterns are relative to the repository root")
38
+ if p.endswith("/"):
39
+ raise PatternError(f"{pattern!r}: trailing '/' is ambiguous; use 'dir/**' instead")
40
+ for segment in p.split("/"):
41
+ if segment in ("", ".", ".."):
42
+ raise PatternError(f"{pattern!r}: empty, '.' and '..' path segments are not allowed")
43
+ if "**" in segment and segment != "**":
44
+ raise PatternError(f"{pattern!r}: '**' must be a complete path segment")
45
+ return p
46
+
47
+
48
+ def _segment_regex(segment: str, original: str) -> str:
49
+ out: list[str] = []
50
+ i, n = 0, len(segment)
51
+ while i < n:
52
+ c = segment[i]
53
+ if c == "*":
54
+ out.append("[^/]*")
55
+ elif c == "?":
56
+ out.append("[^/]")
57
+ elif c == "[":
58
+ j = i + 1
59
+ if j < n and segment[j] in "!^":
60
+ j += 1
61
+ if j < n and segment[j] == "]":
62
+ j += 1
63
+ while j < n and segment[j] != "]":
64
+ j += 1
65
+ if j >= n:
66
+ raise PatternError(f"{original!r}: unclosed '['")
67
+ stuff = segment[i + 1 : j]
68
+ negate = stuff[:1] in ("!", "^")
69
+ if negate:
70
+ stuff = stuff[1:]
71
+ stuff = stuff.replace("\\", "\\\\").replace("[", "\\[")
72
+ out.append("[" + ("^" if negate else "") + stuff + "]")
73
+ i = j
74
+ else:
75
+ out.append(re.escape(c))
76
+ i += 1
77
+ return "".join(out)
78
+
79
+
80
+ @lru_cache(maxsize=2048)
81
+ def compile_pattern(pattern: str) -> re.Pattern[str]:
82
+ normalized = normalize_pattern(pattern)
83
+ segments = normalized.split("/")
84
+ parts: list[str] = []
85
+ for index, segment in enumerate(segments):
86
+ last = index == len(segments) - 1
87
+ if segment == "**":
88
+ parts.append(".+" if last else "(?:[^/]+/)*")
89
+ else:
90
+ parts.append(_segment_regex(segment, pattern))
91
+ if not last:
92
+ parts.append("/")
93
+ return re.compile("".join(parts))
94
+
95
+
96
+ def matches(path: str, pattern: str) -> bool:
97
+ return compile_pattern(pattern).fullmatch(path) is not None
98
+
99
+
100
+ def first_match(path: str, patterns: Iterable[str]) -> str | None:
101
+ for pattern in patterns:
102
+ if matches(path, pattern):
103
+ return pattern
104
+ return None
105
+
106
+
107
+ def matches_any(path: str, patterns: Iterable[str]) -> bool:
108
+ return first_match(path, patterns) is not None
109
+
110
+
111
+ def resolve_within(root: Path, relative: str) -> Path:
112
+ """Resolve ``relative`` under ``root``; refuse anything that escapes it."""
113
+ if not relative or relative.startswith("/") or re.match(r"^[A-Za-z]:", relative):
114
+ raise PathSafetyError(f"unsafe path: {relative!r}")
115
+ if any(part == ".." for part in relative.replace("\\", "/").split("/")):
116
+ raise PathSafetyError(f"path traversal is not allowed: {relative!r}")
117
+ root_resolved = root.resolve()
118
+ candidate = (root_resolved / relative).resolve()
119
+ try:
120
+ candidate.relative_to(root_resolved)
121
+ except ValueError as exc:
122
+ raise PathSafetyError(f"path escapes the repository root: {relative!r}") from exc
123
+ return candidate
124
+
125
+
126
+ def relative_posix(path: Path, root: Path) -> str | None:
127
+ """``path`` relative to ``root`` using ``/``, or ``None`` if it is outside ``root``."""
128
+ try:
129
+ return path.resolve().relative_to(root.resolve()).as_posix()
130
+ except ValueError:
131
+ return None
diffguard/version.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.5
2
+ Name: diffguard-ai
3
+ Version: 0.1.0
4
+ Summary: Guard every AI-generated diff before it reaches a human: policy enforcement for Git changes.
5
+ Project-URL: Homepage, https://github.com/LakshyaDhouchak/diffguard
6
+ Project-URL: Repository, https://github.com/LakshyaDhouchak/diffguard
7
+ Project-URL: Issues, https://github.com/LakshyaDhouchak/diffguard/issues
8
+ Project-URL: Changelog, https://github.com/LakshyaDhouchak/diffguard/blob/main/CHANGELOG.md
9
+ Author: diffguard contributors
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: ai,ci,code-review,diff,git,governance,policy,security
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: Software Development :: Quality Assurance
24
+ Classifier: Topic :: Software Development :: Version Control :: Git
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: pyyaml<7,>=6.0
28
+ Requires-Dist: typer<1,>=0.12
29
+ Provides-Extra: dev
30
+ Requires-Dist: build>=1; extra == 'dev'
31
+ Requires-Dist: jsonschema>=4; extra == 'dev'
32
+ Requires-Dist: mypy>=1.10; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
34
+ Requires-Dist: pytest>=8; extra == 'dev'
35
+ Requires-Dist: ruff>=0.6; extra == 'dev'
36
+ Requires-Dist: twine>=5; extra == 'dev'
37
+ Requires-Dist: types-pyyaml; extra == 'dev'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # diffguard
41
+
42
+ **Guard every AI-generated diff before it reaches a human.**
43
+
44
+ diffguard is an open-source (Apache-2.0) Python library and CLI that checks a Git diff against an
45
+ explicit policy *before* human review: Which files changed? Were they in scope? Were protected paths
46
+ touched? Were secrets, dangerous code, dependency changes, removed tests or sensitive configuration
47
+ introduced? The answer is a deterministic, explainable `pass` / `warn` / `fail` decision with stable exit
48
+ codes for CI.
49
+
50
+ > Status: `0.1.0` (Initial community release candidate). Tested on Linux with Python 3.11-3.13. The CI matrix also covers
51
+ > Windows and macOS, but those platforms had not been executed when this version was cut: check CI results
52
+ > before relying on them. See `docs/architecture.md` for details.
53
+
54
+ ## Why it exists
55
+ AI coding agents modify repositories autonomously: they edit files outside their task, loosen security
56
+ settings, delete tests and add dependencies. Code review evaluates quality *after* the fact. diffguard
57
+ adds a policy layer that enforces boundaries up front, locally, with no cloud, API key or model.
58
+
59
+ ## How it works
60
+ `Git diff + .diffguard.yml policy -> parse -> rules -> findings -> suppressions/baseline -> decision -> reports`
61
+
62
+ Every finding says what happened, where, which rule fired, why it matters and how to fix it.
63
+ Secret values are redacted everywhere.
64
+
65
+ ## Install
66
+ ```bash
67
+ pip install diffguard-ai # after publication; from a checkout: pip install .
68
+ ```
69
+ The PyPI package is **`diffguard-ai`**; the command and the Python import name are `diffguard`
70
+ (`pip install diffguard-ai` -> `diffguard scan` / `import diffguard`).
71
+ Requires Python 3.11+ and Git.
72
+
73
+ ## Quick start
74
+ ```bash
75
+ diffguard init # writes .diffguard.yml
76
+ diffguard validate # checks the policy
77
+ diffguard scan # working tree (incl. untracked) vs HEAD
78
+ diffguard scan --staged
79
+ diffguard scan --base main # branch changes since the merge base
80
+ git diff main... | diffguard scan --diff-file -
81
+ diffguard scan --base main -f json -o report.json
82
+ ```
83
+ Try the end-to-end demo: `python examples/demo.py`.
84
+
85
+ ## Policy
86
+ ```yaml
87
+ version: 1
88
+ task:
89
+ id: "PAY-102"
90
+ allowed_paths: ["src/payments/**", "tests/payments/**"]
91
+ protected_paths: ["src/auth/**", "infrastructure/**", ".github/workflows/**", ".diffguard.yml"]
92
+ max_changed_lines: 150
93
+ rules:
94
+ scope: {severity: error}
95
+ secrets: {severity: error}
96
+ dangerous_patterns: {severity: warning}
97
+ enforcement:
98
+ fail_on: [error]
99
+ ```
100
+ See [docs/configuration.md](docs/configuration.md) and `examples/policies/`.
101
+
102
+ ## Rules
103
+ `scope`, `secrets`, `dangerous_patterns`, `dependency_changes`, `test_removal`, `config_changes`
104
+ (run `diffguard rules`; details in [docs/rules.md](docs/rules.md)). Suppressions, baselines and per-rule
105
+ severity are supported.
106
+
107
+ ## Python API
108
+ ```python
109
+ from diffguard import Scanner, ScanRequest
110
+
111
+ result = Scanner.from_config(".diffguard.yml").scan(ScanRequest(repository=".", base="main"))
112
+ print(result.decision.outcome, int(result.exit_code))
113
+ ```
114
+
115
+ ## JSON report
116
+ Versioned (`schema_version: "1.0"`, [schema](schemas/report-v1.schema.json)): scanner version, timestamp,
117
+ repository metadata, policy, decision, summary counts, findings (with suppression info), rule metadata,
118
+ execution errors and warnings.
119
+
120
+ ## GitHub Actions
121
+ Composite action in `action/` running the same scanner; see [docs/github-actions.md](docs/github-actions.md).
122
+
123
+ ## Exit codes
124
+ `0` no blocking findings, `1` policy violation, `2` invalid config/input, `3` internal/execution failure
125
+ (an incomplete scan never reports success). Details: [docs/cli.md](docs/cli.md).
126
+
127
+ ## Security and privacy
128
+ Local-only, no telemetry, never executes repository code, redacts secrets. Read
129
+ [docs/security.md](docs/security.md) for the threat model.
130
+
131
+ ## Limitations
132
+ Heuristic detection (not complete secret/vulnerability scanning); binary and non-UTF-8 files are not
133
+ inspected; Git-style diffs only; dependency parsing covers a fixed list of formats. Details in
134
+ `docs/security.md` and `docs/rules.md`.
135
+
136
+ ## Detection quality
137
+ A labelled benchmark with documented known misses lives in [benchmarks/](benchmarks/README.md) (hand-written corpus: a
138
+ regression guard, not an accuracy claim). Limits of each rule are listed in [docs/rules.md](docs/rules.md).
139
+
140
+ ## Contributing
141
+ See [CONTRIBUTING.md](CONTRIBUTING.md). License: [Apache-2.0](LICENSE).
@@ -0,0 +1,49 @@
1
+ diffguard/__init__.py,sha256=vVQzi9zLM6drmzGDHunLMk19L1A9uRWxr-wzfsH14Ls,988
2
+ diffguard/__main__.py,sha256=21-VB5AAq9FEX0VipkOgD_8qGzSI_3on7S2Ktdb1xFI,73
3
+ diffguard/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ diffguard/version.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
5
+ diffguard/baselines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ diffguard/baselines/manager.py,sha256=dARX3y88z_j3t7YrM-LG0CA4U4Q_hOiffDhMfCGyc3A,3501
7
+ diffguard/cli/__init__.py,sha256=Oct8QOqd2bL_uExdEs6qa0zGGpZW7UiFMuMsvL1mvcc,44
8
+ diffguard/cli/main.py,sha256=dDr2WGr9IVIxHAWbT2sMbMh8KV_WgD8OPnmUmTaNI2s,11085
9
+ diffguard/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ diffguard/core/enums.py,sha256=DoOQIi7f_shhFhvUbrJ32iYvVeDMYUlJZ6_Eog-toQ4,2126
11
+ diffguard/core/exceptions.py,sha256=4Viu2O7kjWXmF5aSOjzW7BoHySDp-Wkj-8ZJg4uXKc4,1613
12
+ diffguard/core/interfaces.py,sha256=wh_VJUBXYPW8H12RSIT3kbj03AjbjRlCuEixU8HugK4,634
13
+ diffguard/core/models.py,sha256=_E2STY-HNUoMrzCVZyYOtnyRmDG1sO8jbk71ffTViBU,7869
14
+ diffguard/engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ diffguard/engine/evaluator.py,sha256=yxmMijamD9--8eL4kLkwJZ_g-7iZCjWO2Ir4rZ7k3FU,1751
16
+ diffguard/engine/orchestrator.py,sha256=8l8E576f0q1xlkbvjO2QwthC33QqlrbYlEBhfE9QCm8,2762
17
+ diffguard/engine/registry.py,sha256=qFBRdnUviqjGDvUx9qsTyotxudWYTsPePeRQA9Dz0rY,5543
18
+ diffguard/engine/scanner.py,sha256=EmgtevXgoSlx4sO35UDtm16QjGQA9b5pScwiGlvXSn8,5769
19
+ diffguard/git/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ diffguard/git/client.py,sha256=0ZeH9APyb6JPDFT_Psgg0ft_NH1Ka13qNx7bDirzMQA,7770
21
+ diffguard/git/diff_parser.py,sha256=jFW5aysrOX4r8SOk9HLKSNigq-IaciEs9S1L6FXSItw,12627
22
+ diffguard/git/repository.py,sha256=UInm2lI6tHwY4kni7s1z9w4PZ9aOkuB8_3WUt87tsO0,7271
23
+ diffguard/policies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ diffguard/policies/loader.py,sha256=3HB_Ed0lXXCCR3ncpUMLneunsdfCvmprrZx7SxEJhQ8,2672
25
+ diffguard/policies/schema.py,sha256=SloB8EOgP31dgXJ3dbVaooImjlSRuGKEca3Wnv1cc4o,10972
26
+ diffguard/reporting/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ diffguard/reporting/json_report.py,sha256=VNS4UBcRlD_u59L92j-Sz9lFxv41chSL6Zsp-frmt00,3835
28
+ diffguard/reporting/markdown_report.py,sha256=jBghmwLgXQH8TT9c3V4J4SJ1-HF-4uCy65csJdWFYWM,3749
29
+ diffguard/reporting/text_report.py,sha256=0i3xQuZi4tqqWNU2Tp0yQQ1fD-DFo7HTFIlkrjtJ_Sc,1922
30
+ diffguard/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ diffguard/rules/base.py,sha256=MGNvx-0Znjrd5Xu-g5sEwchqcve5eVm-TAclU-HhqQc,8613
32
+ diffguard/rules/configuration.py,sha256=30ZUNA7QmU5GCto4fX3oSek_CF0DbpwrR5HdKVZspwI,5230
33
+ diffguard/rules/dangerous_patterns.py,sha256=Y6wjCgjOhf8bP89hFXbSxEc9EfzwOcobxBtucCeARL0,14269
34
+ diffguard/rules/dependencies.py,sha256=sw4RYlVThenShhqgdVa0-nAh-9G_drDHo_mTezOOelI,15609
35
+ diffguard/rules/filetypes.py,sha256=gAuqhGiKqQJFTsBNEaZ3tC1uqedsV52MF6RGU9X2LpI,1887
36
+ diffguard/rules/scope.py,sha256=Hw5WBehvr1_8HxSqtY8JagzdezD6nOBNxIDscn5c9k8,5349
37
+ diffguard/rules/secret_patterns.py,sha256=4sTdr43pAA0rn2Jb26ila66V4YJvKnbz0JPtjwARfUg,5915
38
+ diffguard/rules/secrets.py,sha256=y4u89NPi__HjYhfaRa4-SFNezPEPMahJxzKcJ3myWWc,5229
39
+ diffguard/rules/test_removal.py,sha256=E9fGva3JDFyvvbWnH7hDFRCVRW3IfNxOgDL2weyeLt0,11490
40
+ diffguard/suppressions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
+ diffguard/suppressions/manager.py,sha256=MEkcdH5wcqZjuCCrK9qi7Np81Mq4Z3rl_edYUFumb2U,3051
42
+ diffguard/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ diffguard/utils/logging.py,sha256=Hr8WloF5dXCuSWZYia4YsuKTJaO9zKX-86mOv2gLwLk,760
44
+ diffguard/utils/paths.py,sha256=ODvQfcT6a36n045sWaTJLY6iKDuKp-vz1YDyOQyY7R0,4976
45
+ diffguard_ai-0.1.0.dist-info/METADATA,sha256=4MiLimw3kzkJRkAoPng7Mt6L5bgfefJMCLGeDZ21QuY,6122
46
+ diffguard_ai-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
47
+ diffguard_ai-0.1.0.dist-info/entry_points.txt,sha256=awqi_NGlczpEBIfR5xAo0mIg_V1m6-AQtVFv_H5Ks7o,53
48
+ diffguard_ai-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
49
+ diffguard_ai-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ diffguard = diffguard.cli.main:app
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.