mouse-claim-audit 0.1.0__tar.gz
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.
- mouse_claim_audit-0.1.0/LICENSE +21 -0
- mouse_claim_audit-0.1.0/MANIFEST.in +2 -0
- mouse_claim_audit-0.1.0/PKG-INFO +37 -0
- mouse_claim_audit-0.1.0/README.md +27 -0
- mouse_claim_audit-0.1.0/mouse_claim_audit/__init__.py +176 -0
- mouse_claim_audit-0.1.0/mouse_claim_audit/__main__.py +3 -0
- mouse_claim_audit-0.1.0/mouse_claim_audit.egg-info/PKG-INFO +37 -0
- mouse_claim_audit-0.1.0/mouse_claim_audit.egg-info/SOURCES.txt +22 -0
- mouse_claim_audit-0.1.0/mouse_claim_audit.egg-info/dependency_links.txt +1 -0
- mouse_claim_audit-0.1.0/mouse_claim_audit.egg-info/entry_points.txt +2 -0
- mouse_claim_audit-0.1.0/mouse_claim_audit.egg-info/top_level.txt +1 -0
- mouse_claim_audit-0.1.0/pyproject.toml +17 -0
- mouse_claim_audit-0.1.0/setup.cfg +4 -0
- mouse_claim_audit-0.1.0/tests/__init__.py +0 -0
- mouse_claim_audit-0.1.0/tests/fixtures/.env +1 -0
- mouse_claim_audit-0.1.0/tests/fixtures/bad/README.md +1 -0
- mouse_claim_audit-0.1.0/tests/fixtures/bad/app.py +1 -0
- mouse_claim_audit-0.1.0/tests/fixtures/good/README.md +1 -0
- mouse_claim_audit-0.1.0/tests/fixtures/good/app.py +2 -0
- mouse_claim_audit-0.1.0/tests/fixtures/no_mouse/README.md +1 -0
- mouse_claim_audit-0.1.0/tests/fixtures/no_mouse/app.py +2 -0
- mouse_claim_audit-0.1.0/tests/fixtures/tests_only/README.md +1 -0
- mouse_claim_audit-0.1.0/tests/fixtures/tests_only/tests/helper.py +2 -0
- mouse_claim_audit-0.1.0/tests/test_audit.py +254 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mouse-claim-audit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mouse-claim-audit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline audit of documented synthetic pointer input
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# mouse-claim-audit
|
|
12
|
+
|
|
13
|
+
An offline static audit of documented synthetic pointer input against Python source calls. Source is parsed as AST and never executed. No dependencies are required at runtime.
|
|
14
|
+
|
|
15
|
+
Install and run:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
python3 -m pip install .
|
|
19
|
+
mouse-claim-audit . --json
|
|
20
|
+
python3 -m mouse_claim_audit . --verbose
|
|
21
|
+
python3 -m unittest discover
|
|
22
|
+
python3 -m build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The positional argument is the repository root. Options: `--json` emits JSON; `--verbose` lists source evidence; repeatable `--ignore <glob>` excludes relative paths; `--fail-on {HIGH,MEDIUM}` sets the failure threshold (default HIGH); `--version` prints the version.
|
|
26
|
+
|
|
27
|
+
Findings carry rule identifiers `documented-mouse-claim-false` and `documented-no-mouse-claim-false`. A positive statement lacking production evidence is HIGH, or MEDIUM when evidence occurs only in tests. A negative statement contradicted by production evidence is HIGH. Each family yields at most one finding. No statement means PASS. Missing source contradicts a positive statement but agrees with a negative one. Exit codes: 0 for PASS, 2 when findings meet the threshold, 1 for usage or root access errors. MEDIUM findings remain visible at the default threshold.
|
|
28
|
+
|
|
29
|
+
Root README.md and Markdown under any docs path component supply statements. Fenced blocks are excluded; inline code counts. Paragraph lines join, case and hyphens are normalized, contractions expand, and exact word boundaries apply. Negative spans are removed before checking positive statements.
|
|
30
|
+
|
|
31
|
+
Production evidence comes from provider-resolved calls through pyautogui, pynput Mouse Controller instances, or autopy.mouse. Module and imported-name aliases are resolved per file. Controller assignment to a name or self attribute and chained construction are supported. Test files are assessed separately. Fixtures, docs, examples, and symlinked files are excluded from evidence. Environment files are never opened.
|
|
32
|
+
|
|
33
|
+
## Limitations
|
|
34
|
+
|
|
35
|
+
Only the exact phrase vocabulary encoded in the package constants is recognized. Bare nouns, user-facing click instructions, and descriptions of keyboard, screen capture, clipboard, voice, or network operations do not count. This tool checks program-driven pointer movement, not whether an action succeeds at runtime.
|
|
36
|
+
|
|
37
|
+
Shell pointer helpers such as xdotool and xte are outside scope. Strings, comments, listeners, widget handlers, and unrelated methods supply no evidence. Analysis is module-local and does not model runtime control flow, rebinding, dynamic imports, or inter-module Controller transfers. Invalid Python syntax is skipped. Static call presence does not establish reachability.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# mouse-claim-audit
|
|
2
|
+
|
|
3
|
+
An offline static audit of documented synthetic pointer input against Python source calls. Source is parsed as AST and never executed. No dependencies are required at runtime.
|
|
4
|
+
|
|
5
|
+
Install and run:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
python3 -m pip install .
|
|
9
|
+
mouse-claim-audit . --json
|
|
10
|
+
python3 -m mouse_claim_audit . --verbose
|
|
11
|
+
python3 -m unittest discover
|
|
12
|
+
python3 -m build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The positional argument is the repository root. Options: `--json` emits JSON; `--verbose` lists source evidence; repeatable `--ignore <glob>` excludes relative paths; `--fail-on {HIGH,MEDIUM}` sets the failure threshold (default HIGH); `--version` prints the version.
|
|
16
|
+
|
|
17
|
+
Findings carry rule identifiers `documented-mouse-claim-false` and `documented-no-mouse-claim-false`. A positive statement lacking production evidence is HIGH, or MEDIUM when evidence occurs only in tests. A negative statement contradicted by production evidence is HIGH. Each family yields at most one finding. No statement means PASS. Missing source contradicts a positive statement but agrees with a negative one. Exit codes: 0 for PASS, 2 when findings meet the threshold, 1 for usage or root access errors. MEDIUM findings remain visible at the default threshold.
|
|
18
|
+
|
|
19
|
+
Root README.md and Markdown under any docs path component supply statements. Fenced blocks are excluded; inline code counts. Paragraph lines join, case and hyphens are normalized, contractions expand, and exact word boundaries apply. Negative spans are removed before checking positive statements.
|
|
20
|
+
|
|
21
|
+
Production evidence comes from provider-resolved calls through pyautogui, pynput Mouse Controller instances, or autopy.mouse. Module and imported-name aliases are resolved per file. Controller assignment to a name or self attribute and chained construction are supported. Test files are assessed separately. Fixtures, docs, examples, and symlinked files are excluded from evidence. Environment files are never opened.
|
|
22
|
+
|
|
23
|
+
## Limitations
|
|
24
|
+
|
|
25
|
+
Only the exact phrase vocabulary encoded in the package constants is recognized. Bare nouns, user-facing click instructions, and descriptions of keyboard, screen capture, clipboard, voice, or network operations do not count. This tool checks program-driven pointer movement, not whether an action succeeds at runtime.
|
|
26
|
+
|
|
27
|
+
Shell pointer helpers such as xdotool and xte are outside scope. Strings, comments, listeners, widget handlers, and unrelated methods supply no evidence. Analysis is module-local and does not model runtime control flow, rebinding, dynamic imports, or inter-module Controller transfers. Invalid Python syntax is skipped. Static call presence does not establish reachability.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""Static documentation and pointer-call auditing."""
|
|
2
|
+
import ast
|
|
3
|
+
import fnmatch
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import re
|
|
8
|
+
import sys
|
|
9
|
+
import argparse
|
|
10
|
+
|
|
11
|
+
__version__ = '0.1.0'
|
|
12
|
+
MOUSE = (
|
|
13
|
+
'automates mouse input', 'automate mouse input', 'simulates mouse input',
|
|
14
|
+
'simulate mouse input', 'moves the mouse automatically', 'move the mouse automatically',
|
|
15
|
+
'clicks buttons automatically', 'click buttons automatically',
|
|
16
|
+
'performs mouse clicks automatically', 'sends mouse clicks', 'send mouse clicks',
|
|
17
|
+
'simulates mouse clicks', 'simulate mouse clicks', 'simulates mouse movement',
|
|
18
|
+
'simulate mouse movement', 'drags and drops automatically', 'drag and drop automatically',
|
|
19
|
+
'automated mouse clicks', 'simulated mouse clicks', 'simulated mouse movement',
|
|
20
|
+
'mouse click automation', 'mouse movement automation', 'mouse input automation', 'mouse automation')
|
|
21
|
+
NOMOUSE = (
|
|
22
|
+
'does not send mouse clicks', 'does not simulate mouse clicks',
|
|
23
|
+
'does not simulate mouse movement', 'does not automate mouse input',
|
|
24
|
+
'does not simulate mouse input', 'does not move the mouse', 'does not click buttons',
|
|
25
|
+
'mouse automation not supported', 'mouse click automation not supported',
|
|
26
|
+
'no mouse automation', 'no mouse click automation', 'without mouse automation',
|
|
27
|
+
'without mouse click automation', 'no mouse input automation')
|
|
28
|
+
PG = set('click doubleClick rightClick leftClick middleClick tripleClick mouseDown mouseUp moveTo moveRel move dragTo dragRel drag scroll hscroll'.split())
|
|
29
|
+
PN = {'click', 'move', 'scroll', 'press', 'release'}
|
|
30
|
+
AP = {'click', 'move', 'smooth_move', 'toggle'}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def normalize(text):
|
|
34
|
+
return re.sub(r'\s+', ' ', text.lower().replace("n't", ' not').replace('-', ' ')).strip()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def pattern(phrases):
|
|
38
|
+
return re.compile(r'\b(?:' + '|'.join(re.escape(p) for p in sorted(phrases, key=len, reverse=True)) + r')\b')
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def claims(text):
|
|
42
|
+
lines = []
|
|
43
|
+
fence = None
|
|
44
|
+
for line in text.splitlines():
|
|
45
|
+
match = re.match(r'^\s{0,3}(`{3,}|~{3,})', line)
|
|
46
|
+
if match:
|
|
47
|
+
token = match.group(1)
|
|
48
|
+
if fence is None:
|
|
49
|
+
fence = token
|
|
50
|
+
elif token[0] == fence[0] and len(token) >= len(fence):
|
|
51
|
+
fence = None
|
|
52
|
+
lines.append('')
|
|
53
|
+
elif fence is None:
|
|
54
|
+
lines.append(line)
|
|
55
|
+
positive = negative = False
|
|
56
|
+
for paragraph in re.split(r'\n\s*\n', '\n'.join(lines)):
|
|
57
|
+
value = normalize(paragraph)
|
|
58
|
+
negative |= bool(pattern(NOMOUSE).search(value))
|
|
59
|
+
value = pattern(NOMOUSE).sub(' ', value)
|
|
60
|
+
positive |= bool(pattern(MOUSE).search(value))
|
|
61
|
+
return positive, negative
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def dotted(node):
|
|
65
|
+
if isinstance(node, ast.Name):
|
|
66
|
+
return node.id
|
|
67
|
+
if isinstance(node, ast.Attribute):
|
|
68
|
+
base = dotted(node.value)
|
|
69
|
+
return base + '.' + node.attr if base else ''
|
|
70
|
+
return ''
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def evidence(text):
|
|
74
|
+
tree = ast.parse(text)
|
|
75
|
+
aliases = {}
|
|
76
|
+
for node in ast.walk(tree):
|
|
77
|
+
if isinstance(node, ast.Import):
|
|
78
|
+
for item in node.names:
|
|
79
|
+
if item.name == 'pynput':
|
|
80
|
+
continue
|
|
81
|
+
if item.name == 'pyautogui' or item.name.startswith('pyautogui.') or item.name == 'autopy' or item.name.startswith('autopy.') or item.name == 'pynput.mouse' or item.name.startswith('pynput.mouse.'):
|
|
82
|
+
aliases[item.asname or item.name.split('.')[0]] = item.name if item.asname else item.name.split('.')[0]
|
|
83
|
+
elif isinstance(node, ast.ImportFrom):
|
|
84
|
+
module = node.module or ''
|
|
85
|
+
for item in node.names:
|
|
86
|
+
if module in ('pyautogui', 'autopy', 'pynput.mouse') or module.startswith(('pyautogui.', 'autopy.', 'pynput.mouse.')) or (module == 'pynput' and item.name == 'mouse'):
|
|
87
|
+
aliases[item.asname or item.name] = module + '.' + item.name
|
|
88
|
+
def resolve(node):
|
|
89
|
+
name = dotted(node)
|
|
90
|
+
first, sep, tail = name.partition('.')
|
|
91
|
+
return aliases.get(first, '') + (sep + tail if sep else '') if first in aliases else ''
|
|
92
|
+
def controller(node):
|
|
93
|
+
return isinstance(node, ast.Call) and resolve(node.func).startswith('pynput.mouse.') and resolve(node.func).split('.')[-1] == 'Controller'
|
|
94
|
+
bound = set()
|
|
95
|
+
for node in ast.walk(tree):
|
|
96
|
+
if isinstance(node, ast.Assign) and controller(node.value):
|
|
97
|
+
for target in node.targets:
|
|
98
|
+
if isinstance(target, ast.Name) or (isinstance(target, ast.Attribute) and isinstance(target.value, ast.Name) and target.value.id == 'self'):
|
|
99
|
+
bound.add(dotted(target))
|
|
100
|
+
hits = []
|
|
101
|
+
for node in ast.walk(tree):
|
|
102
|
+
if not isinstance(node, ast.Call):
|
|
103
|
+
continue
|
|
104
|
+
path = resolve(node.func)
|
|
105
|
+
pg = path.startswith('pyautogui.') and path.split('.')[-1] in PG
|
|
106
|
+
ap = path.startswith('autopy.mouse.') and path.split('.')[-1] in AP and isinstance(node.func, ast.Attribute)
|
|
107
|
+
pn = isinstance(node.func, ast.Attribute) and node.func.attr in PN and (dotted(node.func.value) in bound or controller(node.func.value))
|
|
108
|
+
if pg or ap or pn:
|
|
109
|
+
hits.append(node.lineno)
|
|
110
|
+
return sorted(hits)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def audit(root, ignores=()):
|
|
114
|
+
root = Path(root)
|
|
115
|
+
if not root.is_dir() or not os.access(root, os.R_OK | os.X_OK):
|
|
116
|
+
raise ValueError('root must be a readable directory')
|
|
117
|
+
positive = negative = False
|
|
118
|
+
prod, tests = [], []
|
|
119
|
+
for directory, dirs, files in os.walk(root, followlinks=False):
|
|
120
|
+
dirs[:] = sorted(d for d in dirs if not (Path(directory) / d).is_symlink() and not any(fnmatch.fnmatch((Path(directory) / d).relative_to(root).as_posix(), g) for g in ignores))
|
|
121
|
+
for name in sorted(files):
|
|
122
|
+
path = Path(directory) / name
|
|
123
|
+
rel = path.relative_to(root)
|
|
124
|
+
if path.is_symlink() or any(fnmatch.fnmatch(rel.as_posix(), g) for g in ignores):
|
|
125
|
+
continue
|
|
126
|
+
if name == 'README.md' and len(rel.parts) == 1 or name.endswith('.md') and 'docs' in rel.parts[:-1]:
|
|
127
|
+
p, n = claims(path.read_text(encoding='utf-8'))
|
|
128
|
+
positive |= p
|
|
129
|
+
negative |= n
|
|
130
|
+
if not name.endswith('.py') or any(p in ('fixtures', 'docs', 'examples') for p in rel.parts[:-1]):
|
|
131
|
+
continue
|
|
132
|
+
test = 'tests' in rel.parts[:-1] or name.startswith('test_') or name.endswith('_test.py')
|
|
133
|
+
try:
|
|
134
|
+
hits = evidence(path.read_text(encoding='utf-8'))
|
|
135
|
+
except (SyntaxError, UnicodeError):
|
|
136
|
+
continue
|
|
137
|
+
(tests if test else prod).extend('{}:{}'.format(rel.as_posix(), line) for line in hits)
|
|
138
|
+
findings = []
|
|
139
|
+
if positive and not prod:
|
|
140
|
+
findings.append(dict(rule='documented-mouse-claim-false', severity='MEDIUM' if tests else 'HIGH', message='Documented synthetic pointer input lacks production call evidence.'))
|
|
141
|
+
if negative and prod:
|
|
142
|
+
findings.append(dict(rule='documented-no-mouse-claim-false', severity='HIGH', message='Documented absence conflicts with production pointer calls.'))
|
|
143
|
+
return dict(findings=findings, evidence=prod, test_evidence=tests, claims=dict(mouse=positive, no_mouse=negative))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class Parser(argparse.ArgumentParser):
|
|
147
|
+
def error(self, message):
|
|
148
|
+
self.print_usage(sys.stderr)
|
|
149
|
+
self.exit(1, '{}: error: {}\n'.format(self.prog, message))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def main(argv=None):
|
|
153
|
+
parser = Parser(description=__doc__)
|
|
154
|
+
parser.add_argument('root')
|
|
155
|
+
parser.add_argument('--version', action='version', version=__version__)
|
|
156
|
+
parser.add_argument('--json', action='store_true')
|
|
157
|
+
parser.add_argument('--verbose', action='store_true')
|
|
158
|
+
parser.add_argument('--ignore', action='append', default=[])
|
|
159
|
+
parser.add_argument('--fail-on', choices=['HIGH', 'MEDIUM'], default='HIGH')
|
|
160
|
+
args = parser.parse_args(argv)
|
|
161
|
+
try:
|
|
162
|
+
result = audit(args.root, args.ignore)
|
|
163
|
+
except (OSError, ValueError) as exc:
|
|
164
|
+
parser.exit(1, 'error: {}\n'.format(exc))
|
|
165
|
+
failed = any(f['severity'] == 'HIGH' or args.fail_on == 'MEDIUM' for f in result['findings'])
|
|
166
|
+
result['verdict'] = 'FAIL' if failed else 'PASS'
|
|
167
|
+
if args.json:
|
|
168
|
+
print(json.dumps(result))
|
|
169
|
+
else:
|
|
170
|
+
print(result['verdict'])
|
|
171
|
+
for finding in result['findings']:
|
|
172
|
+
print('{severity} {rule}: {message}'.format(**finding))
|
|
173
|
+
if args.verbose:
|
|
174
|
+
for item in result['evidence'] + result['test_evidence']:
|
|
175
|
+
print('Evidence: ' + item)
|
|
176
|
+
return 2 if failed else 0
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mouse-claim-audit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline audit of documented synthetic pointer input
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# mouse-claim-audit
|
|
12
|
+
|
|
13
|
+
An offline static audit of documented synthetic pointer input against Python source calls. Source is parsed as AST and never executed. No dependencies are required at runtime.
|
|
14
|
+
|
|
15
|
+
Install and run:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
python3 -m pip install .
|
|
19
|
+
mouse-claim-audit . --json
|
|
20
|
+
python3 -m mouse_claim_audit . --verbose
|
|
21
|
+
python3 -m unittest discover
|
|
22
|
+
python3 -m build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The positional argument is the repository root. Options: `--json` emits JSON; `--verbose` lists source evidence; repeatable `--ignore <glob>` excludes relative paths; `--fail-on {HIGH,MEDIUM}` sets the failure threshold (default HIGH); `--version` prints the version.
|
|
26
|
+
|
|
27
|
+
Findings carry rule identifiers `documented-mouse-claim-false` and `documented-no-mouse-claim-false`. A positive statement lacking production evidence is HIGH, or MEDIUM when evidence occurs only in tests. A negative statement contradicted by production evidence is HIGH. Each family yields at most one finding. No statement means PASS. Missing source contradicts a positive statement but agrees with a negative one. Exit codes: 0 for PASS, 2 when findings meet the threshold, 1 for usage or root access errors. MEDIUM findings remain visible at the default threshold.
|
|
28
|
+
|
|
29
|
+
Root README.md and Markdown under any docs path component supply statements. Fenced blocks are excluded; inline code counts. Paragraph lines join, case and hyphens are normalized, contractions expand, and exact word boundaries apply. Negative spans are removed before checking positive statements.
|
|
30
|
+
|
|
31
|
+
Production evidence comes from provider-resolved calls through pyautogui, pynput Mouse Controller instances, or autopy.mouse. Module and imported-name aliases are resolved per file. Controller assignment to a name or self attribute and chained construction are supported. Test files are assessed separately. Fixtures, docs, examples, and symlinked files are excluded from evidence. Environment files are never opened.
|
|
32
|
+
|
|
33
|
+
## Limitations
|
|
34
|
+
|
|
35
|
+
Only the exact phrase vocabulary encoded in the package constants is recognized. Bare nouns, user-facing click instructions, and descriptions of keyboard, screen capture, clipboard, voice, or network operations do not count. This tool checks program-driven pointer movement, not whether an action succeeds at runtime.
|
|
36
|
+
|
|
37
|
+
Shell pointer helpers such as xdotool and xte are outside scope. Strings, comments, listeners, widget handlers, and unrelated methods supply no evidence. Analysis is module-local and does not model runtime control flow, rebinding, dynamic imports, or inter-module Controller transfers. Invalid Python syntax is skipped. Static call presence does not establish reachability.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
mouse_claim_audit/__init__.py
|
|
6
|
+
mouse_claim_audit/__main__.py
|
|
7
|
+
mouse_claim_audit.egg-info/PKG-INFO
|
|
8
|
+
mouse_claim_audit.egg-info/SOURCES.txt
|
|
9
|
+
mouse_claim_audit.egg-info/dependency_links.txt
|
|
10
|
+
mouse_claim_audit.egg-info/entry_points.txt
|
|
11
|
+
mouse_claim_audit.egg-info/top_level.txt
|
|
12
|
+
tests/__init__.py
|
|
13
|
+
tests/test_audit.py
|
|
14
|
+
tests/fixtures/.env
|
|
15
|
+
tests/fixtures/bad/README.md
|
|
16
|
+
tests/fixtures/bad/app.py
|
|
17
|
+
tests/fixtures/good/README.md
|
|
18
|
+
tests/fixtures/good/app.py
|
|
19
|
+
tests/fixtures/no_mouse/README.md
|
|
20
|
+
tests/fixtures/no_mouse/app.py
|
|
21
|
+
tests/fixtures/tests_only/README.md
|
|
22
|
+
tests/fixtures/tests_only/tests/helper.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mouse_claim_audit
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mouse-claim-audit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Offline audit of documented synthetic pointer input"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
mouse-claim-audit = "mouse_claim_audit:main"
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
include = ["mouse_claim_audit*"]
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GUARD_MARKER_ONLY
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
automates mouse input
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import pyautogui
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
automates mouse input
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
no mouse automation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
automates mouse input
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"""Tests 01–30 map to the numbered spec requirements.
|
|
2
|
+
Test 31 exhausts all 24 positive and 14 negative phrases, listed independently
|
|
3
|
+
below, including every phrase not exercised by tests 01–30. Each negative phrase
|
|
4
|
+
also checks span removal, so embedded positive phrases cannot leak through.
|
|
5
|
+
"""
|
|
6
|
+
import contextlib
|
|
7
|
+
import io
|
|
8
|
+
import json
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
import re
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
import tempfile
|
|
14
|
+
import unittest
|
|
15
|
+
from unittest.mock import patch
|
|
16
|
+
|
|
17
|
+
from mouse_claim_audit import audit, claims, evidence, main, normalize
|
|
18
|
+
|
|
19
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
20
|
+
GOOD = 'import pyautogui\npyautogui.click(1, 2)\n'
|
|
21
|
+
POSITIVE = '''automates mouse input|automate mouse input|simulates mouse input|simulate mouse input|moves the mouse automatically|move the mouse automatically|clicks buttons automatically|click buttons automatically|performs mouse clicks automatically|sends mouse clicks|send mouse clicks|simulates mouse clicks|simulate mouse clicks|simulates mouse movement|simulate mouse movement|drags and drops automatically|drag and drop automatically|automated mouse clicks|simulated mouse clicks|simulated mouse movement|mouse click automation|mouse movement automation|mouse input automation|mouse automation'''.split('|')
|
|
22
|
+
NEGATIVE = '''does not send mouse clicks|does not simulate mouse clicks|does not simulate mouse movement|does not automate mouse input|does not simulate mouse input|does not move the mouse|does not click buttons|mouse automation not supported|mouse click automation not supported|no mouse automation|no mouse click automation|without mouse automation|without mouse click automation|no mouse input automation'''.split('|')
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AuditTests(unittest.TestCase):
|
|
26
|
+
def setUp(self):
|
|
27
|
+
self.temp = tempfile.TemporaryDirectory()
|
|
28
|
+
self.addCleanup(self.temp.cleanup)
|
|
29
|
+
self.root = Path(self.temp.name)
|
|
30
|
+
|
|
31
|
+
def write(self, path, text):
|
|
32
|
+
target = self.root / path
|
|
33
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
34
|
+
target.write_text(text, encoding='utf-8')
|
|
35
|
+
return target
|
|
36
|
+
|
|
37
|
+
def cli(self, *args):
|
|
38
|
+
out = io.StringIO()
|
|
39
|
+
with contextlib.redirect_stdout(out):
|
|
40
|
+
code = main([str(self.root), '--json', *args])
|
|
41
|
+
return code, json.loads(out.getvalue())
|
|
42
|
+
|
|
43
|
+
def case(self, source, claim='automates mouse input', severity=None, file='app.py'):
|
|
44
|
+
self.write('README.md', claim)
|
|
45
|
+
if source is not None:
|
|
46
|
+
self.write(file, source)
|
|
47
|
+
code, result = self.cli()
|
|
48
|
+
self.assertEqual(code, 2 if severity == 'HIGH' else 0)
|
|
49
|
+
self.assertEqual([(f['rule'], f['severity']) for f in result['findings']],
|
|
50
|
+
[('documented-mouse-claim-false', severity)] if severity else [])
|
|
51
|
+
return result
|
|
52
|
+
|
|
53
|
+
def test_01_plain(self):
|
|
54
|
+
self.case(GOOD)
|
|
55
|
+
|
|
56
|
+
def test_02_alias(self):
|
|
57
|
+
self.case('import pyautogui as pg\npg.moveTo(1,2)')
|
|
58
|
+
|
|
59
|
+
def test_03_from_alias(self):
|
|
60
|
+
self.case('from pyautogui import dragTo as dg\ndg(1,2)')
|
|
61
|
+
|
|
62
|
+
def test_04_scroll(self):
|
|
63
|
+
self.case('import pyautogui\npyautogui.scroll(1)')
|
|
64
|
+
|
|
65
|
+
def test_05_bound(self):
|
|
66
|
+
self.case('from pynput.mouse import Controller\nctl=Controller()\nctl.click(1)')
|
|
67
|
+
|
|
68
|
+
def test_06_self(self):
|
|
69
|
+
self.case('from pynput.mouse import Controller\nclass A:\n def f(self):\n self.ctl=Controller()\n self.ctl.move(1,2)')
|
|
70
|
+
|
|
71
|
+
def test_07_chain(self):
|
|
72
|
+
self.case('from pynput.mouse import Controller\nController().scroll(1,2)')
|
|
73
|
+
|
|
74
|
+
def test_08_autopy(self):
|
|
75
|
+
self.case('from autopy import mouse\nmouse.click()')
|
|
76
|
+
|
|
77
|
+
def test_09_autopy_alias(self):
|
|
78
|
+
self.case('import autopy as ap\nap.mouse.smooth_move(1,2)')
|
|
79
|
+
|
|
80
|
+
def test_10_import(self):
|
|
81
|
+
self.case('import pyautogui', severity='HIGH')
|
|
82
|
+
|
|
83
|
+
def test_11_string(self):
|
|
84
|
+
self.case('text="click"\nbutton="left"', severity='HIGH')
|
|
85
|
+
|
|
86
|
+
def test_12_keyboard(self):
|
|
87
|
+
self.case('import pyautogui\npyautogui.press("a")\npyautogui.typewrite("a")', severity='HIGH')
|
|
88
|
+
|
|
89
|
+
def test_13_screenshot(self):
|
|
90
|
+
self.case('import pyautogui\npyautogui.screenshot()', severity='HIGH')
|
|
91
|
+
|
|
92
|
+
def test_14_input(self):
|
|
93
|
+
self.case('input("click")', severity='HIGH')
|
|
94
|
+
|
|
95
|
+
def test_15_listener(self):
|
|
96
|
+
self.case('from pynput.mouse import Listener\na=Listener()\na.start()\nwidget.bind("click", handler)', severity='HIGH')
|
|
97
|
+
|
|
98
|
+
def test_16_generic(self):
|
|
99
|
+
self.case('button.click()', severity='HIGH')
|
|
100
|
+
|
|
101
|
+
def test_17_unbound(self):
|
|
102
|
+
self.case('from pynput.mouse import Controller\nctl.click()', severity='HIGH')
|
|
103
|
+
|
|
104
|
+
def test_18_negative(self):
|
|
105
|
+
self.write('README.md', 'no mouse automation')
|
|
106
|
+
self.write('app.py', GOOD)
|
|
107
|
+
code, result = self.cli()
|
|
108
|
+
self.assertEqual(code, 2)
|
|
109
|
+
self.assertEqual([(f['rule'], f['severity']) for f in result['findings']], [('documented-no-mouse-claim-false', 'HIGH')])
|
|
110
|
+
|
|
111
|
+
def test_19_no_claim(self):
|
|
112
|
+
self.case(GOOD, 'A helpful tool.')
|
|
113
|
+
|
|
114
|
+
def test_20_noun(self):
|
|
115
|
+
self.case('import pyautogui', 'the mouse chapter explains delivery')
|
|
116
|
+
|
|
117
|
+
def test_21_instruction(self):
|
|
118
|
+
self.case('import pyautogui', 'click here to continue')
|
|
119
|
+
|
|
120
|
+
def test_22_user_click(self):
|
|
121
|
+
self.case(GOOD, 'click the button to start')
|
|
122
|
+
|
|
123
|
+
def test_23_no_source(self):
|
|
124
|
+
self.case(None, severity='HIGH')
|
|
125
|
+
self.case(None, 'no mouse automation')
|
|
126
|
+
|
|
127
|
+
def test_24_tests_only(self):
|
|
128
|
+
self.case(GOOD, severity='MEDIUM', file='tests/helper.py')
|
|
129
|
+
code, result = self.cli('--fail-on', 'MEDIUM')
|
|
130
|
+
self.assertEqual(code, 2)
|
|
131
|
+
self.assertEqual(result['verdict'], 'FAIL')
|
|
132
|
+
|
|
133
|
+
def test_25_fences(self):
|
|
134
|
+
self.case(None, '```text\nautomates mouse input\n```')
|
|
135
|
+
self.case(None, '`automates mouse input`', 'HIGH')
|
|
136
|
+
|
|
137
|
+
def test_26_negation(self):
|
|
138
|
+
self.assertEqual(claims('does not send mouse clicks'), (False, True))
|
|
139
|
+
self.case(None, 'does not send mouse clicks')
|
|
140
|
+
|
|
141
|
+
def test_27_self(self):
|
|
142
|
+
result = audit(ROOT)
|
|
143
|
+
self.assertEqual(result['findings'], [])
|
|
144
|
+
self.assertEqual(result['claims'], {'mouse': False, 'no_mouse': False})
|
|
145
|
+
text = normalize((ROOT / 'README.md').read_text())
|
|
146
|
+
for phrase in POSITIVE + NEGATIVE:
|
|
147
|
+
self.assertIsNone(re.search(r'\b' + re.escape(phrase) + r'\b', text), phrase)
|
|
148
|
+
|
|
149
|
+
def test_28_cli(self):
|
|
150
|
+
run = subprocess.run([sys.executable, '-m', 'mouse_claim_audit', '--version'], capture_output=True, text=True)
|
|
151
|
+
self.assertEqual((run.returncode, run.stdout.strip()), (0, '0.1.0'))
|
|
152
|
+
self.write('app.py', GOOD)
|
|
153
|
+
self.write('docs/nested/claim.md', 'automates mouse input')
|
|
154
|
+
self.assertTrue(self.cli()[1]['claims']['mouse'])
|
|
155
|
+
self.assertFalse(self.cli('--ignore', 'docs/*')[1]['claims']['mouse'])
|
|
156
|
+
output = io.StringIO()
|
|
157
|
+
with contextlib.redirect_stdout(output):
|
|
158
|
+
self.assertEqual(main([str(self.root), '--verbose']), 0)
|
|
159
|
+
self.assertIn('Evidence: app.py:2', output.getvalue())
|
|
160
|
+
with contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit) as exc:
|
|
161
|
+
main([str(self.root / 'absent')])
|
|
162
|
+
self.assertEqual(exc.exception.code, 1)
|
|
163
|
+
with contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit) as exc:
|
|
164
|
+
main(['--bad-option'])
|
|
165
|
+
self.assertEqual(exc.exception.code, 1)
|
|
166
|
+
|
|
167
|
+
def test_29_env_guard(self):
|
|
168
|
+
self.write('.env', 'GUARD_MARKER_ONLY')
|
|
169
|
+
original = Path.open
|
|
170
|
+
opened = []
|
|
171
|
+
def guarded(path, *args, **kwargs):
|
|
172
|
+
opened.append(str(path))
|
|
173
|
+
self.assertNotEqual(path.name, '.env')
|
|
174
|
+
return original(path, *args, **kwargs)
|
|
175
|
+
with patch.object(Path, 'open', guarded):
|
|
176
|
+
audit(self.root)
|
|
177
|
+
audit(ROOT / 'tests/fixtures')
|
|
178
|
+
self.assertFalse(any(Path(p).name == '.env' for p in opened))
|
|
179
|
+
|
|
180
|
+
def test_30_packaging(self):
|
|
181
|
+
for path in list((ROOT / 'mouse_claim_audit').glob('*.py')) + list((ROOT / 'tests').glob('*.py')) + [ROOT / 'README.md']:
|
|
182
|
+
self.assertIsNone(re.search(r'\bpy' + r'thon\b', path.read_text()), str(path))
|
|
183
|
+
text = (ROOT / 'pyproject.toml').read_text()
|
|
184
|
+
self.assertIn('setuptools>=77', text)
|
|
185
|
+
self.assertIn('license = "MIT"', text)
|
|
186
|
+
self.assertIn('>=3.9', text)
|
|
187
|
+
self.assertIn('recursive-include tests', (ROOT / 'MANIFEST.in').read_text())
|
|
188
|
+
|
|
189
|
+
def test_31_phrase_exhaustion(self):
|
|
190
|
+
self.assertEqual(len(POSITIVE), 24)
|
|
191
|
+
self.assertEqual(len(NEGATIVE), 14)
|
|
192
|
+
for phrase in POSITIVE:
|
|
193
|
+
with self.subTest(positive=phrase):
|
|
194
|
+
self.assertEqual(claims(phrase), (True, False))
|
|
195
|
+
self.case(None, phrase, 'HIGH')
|
|
196
|
+
for phrase in NEGATIVE:
|
|
197
|
+
with self.subTest(negative=phrase):
|
|
198
|
+
self.assertEqual(claims(phrase), (False, True))
|
|
199
|
+
self.write('README.md', phrase)
|
|
200
|
+
self.write('app.py', GOOD)
|
|
201
|
+
code, result = self.cli()
|
|
202
|
+
self.assertEqual(code, 2)
|
|
203
|
+
self.assertEqual([(f['rule'], f['severity']) for f in result['findings']], [('documented-no-mouse-claim-false', 'HIGH')])
|
|
204
|
+
|
|
205
|
+
def test_32_provider_routes(self):
|
|
206
|
+
from mouse_claim_audit import PG, PN, AP
|
|
207
|
+
for method in PG:
|
|
208
|
+
for source in ('import pyautogui as pg\npg.{}()'.format(method), 'from pyautogui import {} as action\naction()'.format(method)):
|
|
209
|
+
with self.subTest(source=source):
|
|
210
|
+
self.assertTrue(evidence(source))
|
|
211
|
+
for method in PN:
|
|
212
|
+
for prefix in ('from pynput import mouse', 'import pynput.mouse as mouse'):
|
|
213
|
+
self.assertTrue(evidence(prefix + '\nc=mouse.Controller()\nc.{}()'.format(method)))
|
|
214
|
+
for method in AP:
|
|
215
|
+
self.assertTrue(evidence('import autopy\nautopy.mouse.{}()'.format(method)))
|
|
216
|
+
self.assertTrue(evidence('from pyautogui.extra import click as c\nc()'))
|
|
217
|
+
self.assertTrue(evidence('from pynput.mouse.extra import Controller as C\nC().click()'))
|
|
218
|
+
|
|
219
|
+
def test_33_non_evidence(self):
|
|
220
|
+
for source in ('import pynput\nc=pynput.mouse.Controller()\nc.click()', 'mouse.click()', 'from other import click\nclick()', 'import keyboard\nkeyboard.send("a")', 'def click():\n print("click")\nclick()', '@app.get("/")\ndef f():\n return "click"', 'import subprocess\nsubprocess.run(["xdotool", "click", "1"])', 'import pyautogui\npyautogui.hotkey("a")\npyautogui.position()', '# pyautogui.click()\n"pyautogui.click()"'):
|
|
221
|
+
with self.subTest(source=source):
|
|
222
|
+
self.assertEqual(evidence(source), [])
|
|
223
|
+
|
|
224
|
+
def test_34_scope_and_symlinks(self):
|
|
225
|
+
self.write('README.md', 'automates mouse input')
|
|
226
|
+
for path in ('fixtures/a.py', 'docs/a.py', 'examples/a.py'):
|
|
227
|
+
self.write(path, GOOD)
|
|
228
|
+
external = self.write('excluded/source.txt', GOOD)
|
|
229
|
+
(self.root / 'linked.py').symlink_to(external)
|
|
230
|
+
self.assertEqual(self.cli()[0], 2)
|
|
231
|
+
self.write('unit_test.py', GOOD)
|
|
232
|
+
self.assertEqual(self.cli()[1]['findings'][0]['severity'], 'MEDIUM')
|
|
233
|
+
self.assertEqual(self.cli('--ignore', '*_test.py')[0], 2)
|
|
234
|
+
|
|
235
|
+
def test_35_normalization(self):
|
|
236
|
+
self.assertEqual(claims('AUTOMATES-MOUSE\nINPUT'), (True, False))
|
|
237
|
+
self.assertEqual(claims("doesn't send mouse clicks"), (False, True))
|
|
238
|
+
self.assertEqual(claims('automates mouse\n\ninput'), (False, False))
|
|
239
|
+
self.assertEqual(claims('xautomates mouse inputx'), (False, False))
|
|
240
|
+
self.assertEqual(claims('~~~\nautomates mouse input\n~~~'), (False, False))
|
|
241
|
+
|
|
242
|
+
def test_36_module_pairing_and_negative_docs(self):
|
|
243
|
+
self.write('README.md', 'automates mouse input')
|
|
244
|
+
self.write('first.py', 'from pynput.mouse import Controller\nc=Controller()')
|
|
245
|
+
self.write('second.py', 'c.click()')
|
|
246
|
+
self.assertEqual(self.cli()[0], 2)
|
|
247
|
+
self.write('first.py', GOOD)
|
|
248
|
+
self.write('README.md', 'A tool.')
|
|
249
|
+
self.write('tests/docs/negative.md', 'no mouse automation')
|
|
250
|
+
self.assertEqual(self.cli()[1]['findings'][0]['rule'], 'documented-no-mouse-claim-false')
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
if __name__ == '__main__':
|
|
254
|
+
unittest.main()
|