iocparser-tool 2.0.0__tar.gz → 3.0.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.
- iocparser_tool-3.0.0/CONTRIBUTING.md +363 -0
- iocparser_tool-3.0.0/Makefile +169 -0
- {iocparser_tool-2.0.0/iocparser_tool.egg-info → iocparser_tool-3.0.0}/PKG-INFO +2 -2
- iocparser_tool-3.0.0/QUALITY.md +340 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/README.md +2 -2
- iocparser_tool-3.0.0/build_package.py +69 -0
- iocparser_tool-3.0.0/examples/README.md +140 -0
- iocparser_tool-3.0.0/examples/sample_report.txt +88 -0
- iocparser_tool-3.0.0/iocparser/README.md +148 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/main.py +2 -2
- iocparser_tool-3.0.0/iocparser/modules/data/misp_warninglists_metadata.json +1 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/extractor.py +147 -27
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/warninglists.py +183 -29
- iocparser_tool-3.0.0/iocparser-cli +13 -0
- iocparser_tool-3.0.0/iocparser.py +14 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0/iocparser_tool.egg-info}/PKG-INFO +2 -2
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser_tool.egg-info/SOURCES.txt +12 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/pyproject.toml +1 -1
- iocparser_tool-3.0.0/setup_quality.sh +152 -0
- iocparser_tool-3.0.0/tests/__init__.py +1 -0
- iocparser_tool-3.0.0/tox.ini +122 -0
- iocparser_tool-2.0.0/iocparser/modules/data/misp_warninglists_metadata.json +0 -1
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/LICENSE +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/MANIFEST.in +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/__init__.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/__init__.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/data/misp_warninglists_cache.json +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/exceptions.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/file_parser.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/logger.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/output_formatter.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser/modules/streaming.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser_tool.egg-info/dependency_links.txt +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser_tool.egg-info/entry_points.txt +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser_tool.egg-info/not-zip-safe +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser_tool.egg-info/requires.txt +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/iocparser_tool.egg-info/top_level.txt +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/requirements.txt +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/setup.cfg +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/setup.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/tests/test_basic.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/tests/test_duplicate_removal.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/tests/test_duplicate_removal_simple.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/tests/test_extractors.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/tests/test_performance.py +0 -0
- {iocparser_tool-2.0.0 → iocparser_tool-3.0.0}/tests/test_warninglists.py +0 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
# Contributing to IOCParser
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to IOCParser! This document provides guidelines and instructions for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Development Setup](#development-setup)
|
|
10
|
+
- [Making Contributions](#making-contributions)
|
|
11
|
+
- [Coding Standards](#coding-standards)
|
|
12
|
+
- [Testing](#testing)
|
|
13
|
+
- [Documentation](#documentation)
|
|
14
|
+
- [Submitting Changes](#submitting-changes)
|
|
15
|
+
|
|
16
|
+
## Code of Conduct
|
|
17
|
+
|
|
18
|
+
By participating in this project, you agree to abide by our code of conduct:
|
|
19
|
+
|
|
20
|
+
- Be respectful and inclusive
|
|
21
|
+
- Welcome newcomers and help them get started
|
|
22
|
+
- Focus on constructive criticism
|
|
23
|
+
- Accept feedback gracefully
|
|
24
|
+
- Prioritize the project's best interests
|
|
25
|
+
|
|
26
|
+
## Getting Started
|
|
27
|
+
|
|
28
|
+
1. Fork the repository on GitHub
|
|
29
|
+
2. Clone your fork locally:
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/YOUR_USERNAME/iocparser.git
|
|
32
|
+
cd iocparser
|
|
33
|
+
```
|
|
34
|
+
3. Add the upstream repository:
|
|
35
|
+
```bash
|
|
36
|
+
git remote add upstream https://github.com/seifreed/iocparser.git
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Development Setup
|
|
40
|
+
|
|
41
|
+
### Prerequisites
|
|
42
|
+
|
|
43
|
+
- Python 3.8 or higher
|
|
44
|
+
- pip and virtualenv
|
|
45
|
+
- Git
|
|
46
|
+
|
|
47
|
+
### Setting Up Your Environment
|
|
48
|
+
|
|
49
|
+
1. Create a virtual environment:
|
|
50
|
+
```bash
|
|
51
|
+
python -m venv venv
|
|
52
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. Install the package in development mode:
|
|
56
|
+
```bash
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
3. Install development dependencies:
|
|
61
|
+
```bash
|
|
62
|
+
pip install -e ".[dev]"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
4. Install pre-commit hooks:
|
|
66
|
+
```bash
|
|
67
|
+
pre-commit install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Making Contributions
|
|
71
|
+
|
|
72
|
+
### Types of Contributions
|
|
73
|
+
|
|
74
|
+
We welcome various types of contributions:
|
|
75
|
+
|
|
76
|
+
- **Bug Fixes**: Fix issues reported in GitHub Issues
|
|
77
|
+
- **New Features**: Add new IOC extraction capabilities
|
|
78
|
+
- **Performance Improvements**: Optimize existing code
|
|
79
|
+
- **Documentation**: Improve or add documentation
|
|
80
|
+
- **Tests**: Add or improve test coverage
|
|
81
|
+
- **Refactoring**: Improve code structure and readability
|
|
82
|
+
|
|
83
|
+
### Workflow
|
|
84
|
+
|
|
85
|
+
1. **Create a Branch**:
|
|
86
|
+
```bash
|
|
87
|
+
git checkout -b feature/your-feature-name
|
|
88
|
+
# or
|
|
89
|
+
git checkout -b fix/issue-number
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
2. **Make Your Changes**: Follow our coding standards (see below)
|
|
93
|
+
|
|
94
|
+
3. **Write/Update Tests**: Ensure your changes are tested
|
|
95
|
+
|
|
96
|
+
4. **Run Tests Locally**:
|
|
97
|
+
```bash
|
|
98
|
+
pytest tests/
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
5. **Check Code Quality**:
|
|
102
|
+
```bash
|
|
103
|
+
black iocparser/
|
|
104
|
+
flake8 iocparser/
|
|
105
|
+
mypy iocparser/
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
6. **Commit Your Changes**:
|
|
109
|
+
```bash
|
|
110
|
+
git add .
|
|
111
|
+
git commit -m "feat: add support for extracting X IOC type"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Commit Message Format
|
|
115
|
+
|
|
116
|
+
We use conventional commits format:
|
|
117
|
+
|
|
118
|
+
- `feat:` New feature
|
|
119
|
+
- `fix:` Bug fix
|
|
120
|
+
- `docs:` Documentation changes
|
|
121
|
+
- `style:` Code style changes (formatting, etc.)
|
|
122
|
+
- `refactor:` Code refactoring
|
|
123
|
+
- `perf:` Performance improvements
|
|
124
|
+
- `test:` Test additions or changes
|
|
125
|
+
- `chore:` Maintenance tasks
|
|
126
|
+
|
|
127
|
+
Examples:
|
|
128
|
+
```
|
|
129
|
+
feat: add extraction support for MITRE ATT&CK IDs
|
|
130
|
+
fix: correct IPv6 regex pattern matching
|
|
131
|
+
docs: update README with new IOC types
|
|
132
|
+
perf: optimize domain extraction for large files
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Coding Standards
|
|
136
|
+
|
|
137
|
+
### Python Style Guide
|
|
138
|
+
|
|
139
|
+
We follow PEP 8 with some modifications:
|
|
140
|
+
|
|
141
|
+
- Maximum line length: 100 characters
|
|
142
|
+
- Use type hints for all function signatures
|
|
143
|
+
- Use docstrings for all public functions and classes
|
|
144
|
+
|
|
145
|
+
### Code Formatting
|
|
146
|
+
|
|
147
|
+
We use `black` for automatic code formatting:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
black --line-length 100 iocparser/
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Type Hints
|
|
154
|
+
|
|
155
|
+
All new code should include type hints:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from typing import List, Dict, Optional
|
|
159
|
+
|
|
160
|
+
def extract_iocs(text: str, defang: bool = True) -> Dict[str, List[str]]:
|
|
161
|
+
"""
|
|
162
|
+
Extract IOCs from text.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
text: Input text to process
|
|
166
|
+
defang: Whether to defang extracted IOCs
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
Dictionary mapping IOC types to lists of IOCs
|
|
170
|
+
"""
|
|
171
|
+
pass
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Docstrings
|
|
175
|
+
|
|
176
|
+
Use Google-style docstrings:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
def function_name(param1: str, param2: int) -> bool:
|
|
180
|
+
"""
|
|
181
|
+
Brief description of the function.
|
|
182
|
+
|
|
183
|
+
More detailed description if needed.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
param1: Description of param1
|
|
187
|
+
param2: Description of param2
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
Description of return value
|
|
191
|
+
|
|
192
|
+
Raises:
|
|
193
|
+
ValueError: When invalid input is provided
|
|
194
|
+
"""
|
|
195
|
+
pass
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Testing
|
|
199
|
+
|
|
200
|
+
### Writing Tests
|
|
201
|
+
|
|
202
|
+
- Write tests for all new functionality
|
|
203
|
+
- Place tests in the `tests/` directory
|
|
204
|
+
- Use descriptive test names
|
|
205
|
+
- Include edge cases and error conditions
|
|
206
|
+
|
|
207
|
+
Example test:
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
def test_extract_md5_valid():
|
|
211
|
+
"""Test extraction of valid MD5 hashes."""
|
|
212
|
+
extractor = IOCExtractor()
|
|
213
|
+
text = "Hash: 5f4dcc3b5aa765d61d8327deb882cf99"
|
|
214
|
+
result = extractor.extract_md5(text)
|
|
215
|
+
assert len(result) == 1
|
|
216
|
+
assert "5f4dcc3b5aa765d61d8327deb882cf99" in result
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Running Tests
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Run all tests
|
|
223
|
+
pytest tests/
|
|
224
|
+
|
|
225
|
+
# Run with coverage
|
|
226
|
+
pytest tests/ --cov=iocparser --cov-report=term-missing
|
|
227
|
+
|
|
228
|
+
# Run specific test file
|
|
229
|
+
pytest tests/test_extractors.py
|
|
230
|
+
|
|
231
|
+
# Run tests in verbose mode
|
|
232
|
+
pytest tests/ -v
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Performance Testing
|
|
236
|
+
|
|
237
|
+
For performance-critical changes:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
pytest tests/test_performance.py --benchmark-only
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Documentation
|
|
244
|
+
|
|
245
|
+
### Code Documentation
|
|
246
|
+
|
|
247
|
+
- Add docstrings to all public functions and classes
|
|
248
|
+
- Update existing docstrings when changing functionality
|
|
249
|
+
- Include examples in docstrings for complex functions
|
|
250
|
+
|
|
251
|
+
### README Updates
|
|
252
|
+
|
|
253
|
+
Update the README.md when:
|
|
254
|
+
- Adding new IOC types
|
|
255
|
+
- Changing command-line interface
|
|
256
|
+
- Adding new features
|
|
257
|
+
- Changing installation requirements
|
|
258
|
+
|
|
259
|
+
### API Documentation
|
|
260
|
+
|
|
261
|
+
For significant API changes, update the documentation:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Generate API documentation
|
|
265
|
+
sphinx-build -b html docs/ docs/_build/
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Submitting Changes
|
|
269
|
+
|
|
270
|
+
### Pull Request Process
|
|
271
|
+
|
|
272
|
+
1. **Update Your Fork**:
|
|
273
|
+
```bash
|
|
274
|
+
git fetch upstream
|
|
275
|
+
git checkout main
|
|
276
|
+
git merge upstream/main
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
2. **Rebase Your Branch**:
|
|
280
|
+
```bash
|
|
281
|
+
git checkout your-branch
|
|
282
|
+
git rebase main
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
3. **Push to Your Fork**:
|
|
286
|
+
```bash
|
|
287
|
+
git push origin your-branch
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
4. **Create Pull Request**:
|
|
291
|
+
- Go to GitHub and create a pull request
|
|
292
|
+
- Fill in the PR template
|
|
293
|
+
- Link related issues
|
|
294
|
+
- Ensure CI checks pass
|
|
295
|
+
|
|
296
|
+
### PR Requirements
|
|
297
|
+
|
|
298
|
+
Before submitting a PR, ensure:
|
|
299
|
+
|
|
300
|
+
- [ ] All tests pass
|
|
301
|
+
- [ ] Code follows style guidelines
|
|
302
|
+
- [ ] Documentation is updated
|
|
303
|
+
- [ ] Commit messages follow convention
|
|
304
|
+
- [ ] PR description clearly explains changes
|
|
305
|
+
- [ ] Related issues are linked
|
|
306
|
+
|
|
307
|
+
### Review Process
|
|
308
|
+
|
|
309
|
+
1. Maintainers will review your PR
|
|
310
|
+
2. Address any feedback or requested changes
|
|
311
|
+
3. Once approved, your PR will be merged
|
|
312
|
+
|
|
313
|
+
## Adding New IOC Types
|
|
314
|
+
|
|
315
|
+
When adding support for new IOC types:
|
|
316
|
+
|
|
317
|
+
1. **Add Regex Pattern** in `extractor.py`:
|
|
318
|
+
```python
|
|
319
|
+
self.patterns['new_ioc_type'] = re.compile(r'pattern')
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
2. **Add Extraction Method**:
|
|
323
|
+
```python
|
|
324
|
+
def extract_new_ioc_type(self, text: str) -> List[str]:
|
|
325
|
+
"""Extract new IOC type from text."""
|
|
326
|
+
return self._extract_pattern(text, 'new_ioc_type')
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
3. **Update `extract_all` Method**:
|
|
330
|
+
```python
|
|
331
|
+
('new_ioc_type', self.extract_new_ioc_type),
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
4. **Add Tests**:
|
|
335
|
+
```python
|
|
336
|
+
def test_extract_new_ioc_type():
|
|
337
|
+
# Test implementation
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
5. **Update Documentation**:
|
|
341
|
+
- Add to README.md features list
|
|
342
|
+
- Update API documentation
|
|
343
|
+
|
|
344
|
+
## Questions and Support
|
|
345
|
+
|
|
346
|
+
If you have questions:
|
|
347
|
+
|
|
348
|
+
1. Check existing [issues](https://github.com/seifreed/iocparser/issues)
|
|
349
|
+
2. Search the [documentation](https://github.com/seifreed/iocparser#readme)
|
|
350
|
+
3. Create a new issue with the question label
|
|
351
|
+
|
|
352
|
+
## License
|
|
353
|
+
|
|
354
|
+
By contributing to IOCParser, you agree that your contributions will be licensed under the MIT License.
|
|
355
|
+
|
|
356
|
+
## Recognition
|
|
357
|
+
|
|
358
|
+
Contributors will be recognized in:
|
|
359
|
+
- The project's contributors list
|
|
360
|
+
- Release notes for significant contributions
|
|
361
|
+
- The AUTHORS file (for major contributors)
|
|
362
|
+
|
|
363
|
+
Thank you for contributing to IOCParser!
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
.PHONY: help install install-dev clean test lint format security check-all pre-commit build docs
|
|
2
|
+
|
|
3
|
+
# Variables
|
|
4
|
+
PYTHON := python3
|
|
5
|
+
PIP := $(PYTHON) -m pip
|
|
6
|
+
PROJECT_NAME := iocparser
|
|
7
|
+
SRC_DIR := iocparser
|
|
8
|
+
TEST_DIR := tests
|
|
9
|
+
|
|
10
|
+
# Colors for output
|
|
11
|
+
RED := \033[0;31m
|
|
12
|
+
GREEN := \033[0;32m
|
|
13
|
+
YELLOW := \033[1;33m
|
|
14
|
+
NC := \033[0m # No Color
|
|
15
|
+
|
|
16
|
+
help: ## Show this help message
|
|
17
|
+
@echo "$(GREEN)IOCParser Development Commands$(NC)"
|
|
18
|
+
@echo ""
|
|
19
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-20s$(NC) %s\n", $$1, $$2}'
|
|
20
|
+
|
|
21
|
+
install: ## Install the package in production mode
|
|
22
|
+
$(PIP) install -e .
|
|
23
|
+
@echo "$(GREEN)✓ IOCParser installed successfully$(NC)"
|
|
24
|
+
|
|
25
|
+
install-dev: ## Install the package with development dependencies
|
|
26
|
+
$(PIP) install -e ".[dev]"
|
|
27
|
+
pre-commit install
|
|
28
|
+
@echo "$(GREEN)✓ Development environment setup complete$(NC)"
|
|
29
|
+
|
|
30
|
+
clean: ## Clean build artifacts and cache files
|
|
31
|
+
rm -rf build/ dist/ *.egg-info
|
|
32
|
+
rm -rf .coverage htmlcov/ .pytest_cache/
|
|
33
|
+
rm -rf .mypy_cache/ .ruff_cache/
|
|
34
|
+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
35
|
+
find . -type f -name "*.pyc" -delete
|
|
36
|
+
find . -type f -name "*.pyo" -delete
|
|
37
|
+
find . -type f -name "*~" -delete
|
|
38
|
+
@echo "$(GREEN)✓ Cleaned build artifacts and cache files$(NC)"
|
|
39
|
+
|
|
40
|
+
test: ## Run all tests with coverage
|
|
41
|
+
pytest $(TEST_DIR) -v --cov=$(SRC_DIR) --cov-report=term-missing --cov-report=html
|
|
42
|
+
@echo "$(GREEN)✓ Tests completed. Coverage report available in htmlcov/index.html$(NC)"
|
|
43
|
+
|
|
44
|
+
test-fast: ## Run tests without coverage (faster)
|
|
45
|
+
pytest $(TEST_DIR) -v
|
|
46
|
+
@echo "$(GREEN)✓ Tests completed$(NC)"
|
|
47
|
+
|
|
48
|
+
test-benchmark: ## Run performance benchmark tests
|
|
49
|
+
pytest $(TEST_DIR)/test_performance.py -v --benchmark-only
|
|
50
|
+
@echo "$(GREEN)✓ Benchmark tests completed$(NC)"
|
|
51
|
+
|
|
52
|
+
lint: ## Run all linters (ruff, mypy, pylint)
|
|
53
|
+
@echo "$(YELLOW)Running Ruff...$(NC)"
|
|
54
|
+
ruff check $(SRC_DIR) $(TEST_DIR)
|
|
55
|
+
@echo "$(YELLOW)Running MyPy...$(NC)"
|
|
56
|
+
mypy $(SRC_DIR)
|
|
57
|
+
@echo "$(YELLOW)Running Pylint...$(NC)"
|
|
58
|
+
pylint $(SRC_DIR) || true
|
|
59
|
+
@echo "$(GREEN)✓ Linting completed$(NC)"
|
|
60
|
+
|
|
61
|
+
format: ## Auto-format code with ruff
|
|
62
|
+
ruff check --fix $(SRC_DIR) $(TEST_DIR)
|
|
63
|
+
ruff format $(SRC_DIR) $(TEST_DIR)
|
|
64
|
+
@echo "$(GREEN)✓ Code formatted$(NC)"
|
|
65
|
+
|
|
66
|
+
security: ## Run security checks (bandit, safety)
|
|
67
|
+
@echo "$(YELLOW)Running Bandit security scan...$(NC)"
|
|
68
|
+
bandit -r $(SRC_DIR) -ll
|
|
69
|
+
@echo "$(YELLOW)Checking for known vulnerabilities in dependencies...$(NC)"
|
|
70
|
+
safety check --json || true
|
|
71
|
+
pip-audit || true
|
|
72
|
+
@echo "$(GREEN)✓ Security checks completed$(NC)"
|
|
73
|
+
|
|
74
|
+
check-all: lint test security ## Run all checks (lint, test, security)
|
|
75
|
+
@echo "$(GREEN)✓ All checks completed successfully$(NC)"
|
|
76
|
+
|
|
77
|
+
pre-commit: ## Run pre-commit hooks on all files
|
|
78
|
+
pre-commit run --all-files
|
|
79
|
+
@echo "$(GREEN)✓ Pre-commit hooks completed$(NC)"
|
|
80
|
+
|
|
81
|
+
pre-commit-update: ## Update pre-commit hooks to latest versions
|
|
82
|
+
pre-commit autoupdate
|
|
83
|
+
@echo "$(GREEN)✓ Pre-commit hooks updated$(NC)"
|
|
84
|
+
|
|
85
|
+
build: clean ## Build distribution packages
|
|
86
|
+
$(PYTHON) -m build
|
|
87
|
+
@echo "$(GREEN)✓ Distribution packages built in dist/$(NC)"
|
|
88
|
+
|
|
89
|
+
publish-test: build ## Publish to TestPyPI (for testing)
|
|
90
|
+
$(PYTHON) -m twine upload --repository testpypi dist/*
|
|
91
|
+
@echo "$(GREEN)✓ Published to TestPyPI$(NC)"
|
|
92
|
+
|
|
93
|
+
publish: build ## Publish to PyPI (requires credentials)
|
|
94
|
+
$(PYTHON) -m twine upload dist/*
|
|
95
|
+
@echo "$(GREEN)✓ Published to PyPI$(NC)"
|
|
96
|
+
|
|
97
|
+
docs: ## Generate API documentation
|
|
98
|
+
pdoc --html --output-dir docs $(SRC_DIR) --force
|
|
99
|
+
@echo "$(GREEN)✓ Documentation generated in docs/$(NC)"
|
|
100
|
+
|
|
101
|
+
quality-report: ## Generate comprehensive quality report
|
|
102
|
+
@echo "$(YELLOW)Generating Quality Report...$(NC)"
|
|
103
|
+
@echo "================================"
|
|
104
|
+
@echo "Code Coverage:"
|
|
105
|
+
@pytest $(TEST_DIR) --cov=$(SRC_DIR) --cov-report=term | grep TOTAL || true
|
|
106
|
+
@echo ""
|
|
107
|
+
@echo "Code Complexity:"
|
|
108
|
+
@ruff check $(SRC_DIR) --select C901 --statistics || true
|
|
109
|
+
@echo ""
|
|
110
|
+
@echo "Type Coverage:"
|
|
111
|
+
@mypy $(SRC_DIR) --html-report mypy_report 2>&1 | grep "Success:" || true
|
|
112
|
+
@echo ""
|
|
113
|
+
@echo "Security Issues:"
|
|
114
|
+
@bandit -r $(SRC_DIR) -f json 2>/dev/null | python -m json.tool | grep '"issue_severity"' | wc -l | xargs echo "Total issues found:" || true
|
|
115
|
+
@echo "$(GREEN)✓ Quality report completed$(NC)"
|
|
116
|
+
|
|
117
|
+
init-misp: ## Initialize MISP warning lists
|
|
118
|
+
iocparser --init
|
|
119
|
+
@echo "$(GREEN)✓ MISP warning lists initialized$(NC)"
|
|
120
|
+
|
|
121
|
+
example: ## Run IOCParser on the example file
|
|
122
|
+
iocparser -f examples/sample_report.txt --json
|
|
123
|
+
@echo "$(GREEN)✓ Example completed$(NC)"
|
|
124
|
+
|
|
125
|
+
dev-install: install-dev ## Alias for install-dev
|
|
126
|
+
|
|
127
|
+
setup: install-dev init-misp ## Complete setup (install + MISP lists)
|
|
128
|
+
@echo "$(GREEN)✓ Complete setup finished$(NC)"
|
|
129
|
+
|
|
130
|
+
watch: ## Watch for file changes and run tests
|
|
131
|
+
watchmedo shell-command --patterns="*.py" --recursive --command="make test-fast" $(SRC_DIR) $(TEST_DIR)
|
|
132
|
+
|
|
133
|
+
ci: ## Run CI pipeline locally
|
|
134
|
+
@echo "$(YELLOW)Running CI pipeline...$(NC)"
|
|
135
|
+
make lint
|
|
136
|
+
make test
|
|
137
|
+
make security
|
|
138
|
+
@echo "$(GREEN)✓ CI pipeline completed successfully$(NC)"
|
|
139
|
+
|
|
140
|
+
stats: ## Show code statistics
|
|
141
|
+
@echo "$(YELLOW)Code Statistics:$(NC)"
|
|
142
|
+
@echo "Lines of code:"
|
|
143
|
+
@find $(SRC_DIR) -name "*.py" -exec wc -l {} + | tail -1
|
|
144
|
+
@echo "Number of Python files:"
|
|
145
|
+
@find $(SRC_DIR) -name "*.py" | wc -l
|
|
146
|
+
@echo "Number of tests:"
|
|
147
|
+
@grep -r "def test_" $(TEST_DIR) | wc -l
|
|
148
|
+
@echo "$(GREEN)✓ Statistics generated$(NC)"
|
|
149
|
+
|
|
150
|
+
update-deps: ## Update all dependencies to latest versions
|
|
151
|
+
$(PIP) list --outdated
|
|
152
|
+
$(PIP) install --upgrade pip setuptools wheel
|
|
153
|
+
$(PIP) install --upgrade -r requirements.txt
|
|
154
|
+
@echo "$(GREEN)✓ Dependencies updated$(NC)"
|
|
155
|
+
|
|
156
|
+
freeze: ## Freeze current dependencies
|
|
157
|
+
$(PIP) freeze > requirements-freeze.txt
|
|
158
|
+
@echo "$(GREEN)✓ Dependencies frozen to requirements-freeze.txt$(NC)"
|
|
159
|
+
|
|
160
|
+
validate: ## Validate project configuration files
|
|
161
|
+
@echo "$(YELLOW)Validating configuration files...$(NC)"
|
|
162
|
+
python -m py_compile $(SRC_DIR)/*.py $(SRC_DIR)/**/*.py
|
|
163
|
+
python -c "import toml; toml.load('pyproject.toml')"
|
|
164
|
+
yamllint .pre-commit-config.yaml
|
|
165
|
+
yamllint .github/workflows/*.yml
|
|
166
|
+
@echo "$(GREEN)✓ All configuration files are valid$(NC)"
|
|
167
|
+
|
|
168
|
+
# Default target
|
|
169
|
+
.DEFAULT_GOAL := help
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: iocparser-tool
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: A tool for extracting Indicators of Compromise from security reports
|
|
5
5
|
Home-page: https://github.com/seifreed/iocparser
|
|
6
6
|
Author: Marc Rivero
|
|
@@ -60,7 +60,7 @@ Dynamic: requires-python
|
|
|
60
60
|
A tool for extracting Indicators of Compromise (IOCs) from security reports in HTML, PDF, and plain text formats.
|
|
61
61
|
|
|
62
62
|
Author: Marc Rivero | @seifreed
|
|
63
|
-
Version:
|
|
63
|
+
Version: 2.0.0
|
|
64
64
|
|
|
65
65
|
## Features
|
|
66
66
|
|