|
27 | 27 | gpg_keyring: none (defaults to user's GPG keyring) or string (path to keyring file) |
28 | 28 | """ |
29 | 29 | from datetime import datetime, timedelta |
| 30 | +from typing import Optional |
| 31 | +from io import BytesIO |
30 | 32 |
|
31 | 33 | from intelmq.lib.bot import CollectorBot |
32 | 34 | from intelmq.lib.mixins import HttpMixin |
33 | 35 | from intelmq.lib.utils import unzip |
34 | 36 | from intelmq.lib.exceptions import MissingDependencyError |
| 37 | +from intelmq.lib.splitreports import generate_reports |
35 | 38 |
|
36 | 39 | try: |
37 | 40 | import gnupg |
@@ -64,6 +67,9 @@ class HTTPCollectorBot(CollectorBot, HttpMixin): |
64 | 67 | signature_url_formatting: bool = False |
65 | 68 | ssl_client_certificate: str = None # TODO: pathlib.Path |
66 | 69 | verify_pgp_signatures: bool = False |
| 70 | + # splitreports |
| 71 | + chunk_replicate_header: bool = True |
| 72 | + chunk_size: Optional[int] = None |
67 | 73 |
|
68 | 74 | def init(self): |
69 | 75 | self.use_gpg = self.verify_pgp_signatures |
@@ -130,12 +136,15 @@ def process(self): |
130 | 136 | return_names=True, logger=self.logger) |
131 | 137 |
|
132 | 138 | for file_name, raw_report in raw_reports: |
133 | | - report = self.new_report() |
134 | | - report.add("raw", raw_report) |
135 | | - report.add("feed.url", http_url) |
| 139 | + template = self.new_report() |
| 140 | + template.add("raw", raw_report) |
| 141 | + template.add("feed.url", http_url) |
136 | 142 | if file_name: |
137 | 143 | report.add("extra.file_name", file_name) |
138 | | - self.send_message(report) |
| 144 | + for report in generate_reports(template, BytesIO(resp.content), |
| 145 | + self.chunk_size, |
| 146 | + self.chunk_replicate_header): |
| 147 | + self.send_message(report) |
139 | 148 |
|
140 | 149 | def format_url(self, url: str, formatting) -> str: |
141 | 150 | try: |
|
0 commit comments