iobroker.parser
Advanced tools
Comparing version 1.1.8 to 1.2.0
@@ -42,3 +42,6 @@ { | ||
"temperature": "temperature", | ||
"value": "value" | ||
} | ||
"value": "value", | ||
"Request Timeout": "Request Timeout", | ||
"Accept invalid certificates": "Accept invalid certificates", | ||
"Use insecure HTTP parser": "Use insecure HTTP parser" | ||
} |
{ | ||
"common": { | ||
"name": "parser", | ||
"version": "1.1.8", | ||
"version": "1.2.0", | ||
"news": { | ||
"1.2.0": { | ||
"en": "Allow to specify if self-signed/invalid SSL certificates are ignored or not (default is to ignore as till now)\nAllow to specify if an \"insecure HTTP parser\" is used which also enables HTTP implementations that are not compliant to specifications\nAllow to specify the HTTP request timeout", | ||
"de": "Geben Sie an, ob selbstsignierte/ungültige SSL-Zertifikate ignoriert oder nicht (Standard ist, wie bisher ignoriert)\nGeben Sie an, ob ein \"unsicherer HTTP-Parser\" verwendet wird, der auch HTTP-Implementierungen ermöglicht, die nicht den Spezifikationen entsprechen\nErlauben Sie, den HTTP-Anforderungszeitpunkt anzugeben", | ||
"ru": "Разрешить указать, если самоподписанные / недействительные SSL сертификаты игнорируются или нет (по умолчанию не следует игнорировать, как до сих пор)\nРазрешить указать, используется ли «небезопасный HTTP-парсер», что также позволяет HTTP-реализациям, которые не соответствуют спецификациям\nРазрешить указать timeout запроса HTTP", | ||
"pt": "Permitir especificar se certificados SSL auto-assinados/inválidos são ignorados ou não (o padrão é ignorar como até agora)\nPermitir especificar se um \"parser HTTP inseguro\" é usado que também permite implementações HTTP que não estão em conformidade com as especificações\nPermitir especificar o prazo de solicitação HTTP", | ||
"nl": "Sta toe te specificeren of zelf toegewezen/invalide SSL certificaten worden genegeerd of niet (default is om te negeren als tot nu toe\nOm te specificeren of een \"onduidelijke HTP-papieren\" gebruikt wordt, die ook HTP implementaties in staat stelt die niet compliceren voor specifieke details\nMag ik de HTP verzoeken verlenen", | ||
"fr": "Permettre de spécifier si les certificats SSL autosignés/invalides sont ignorés ou non (par défaut, il faut ignorer comme maintenant)\nPermet de spécifier si un \"Parser HTTP insecure\" est utilisé qui permet également des implémentations HTTP qui ne sont pas conformes aux spécifications\nPermet de spécifier le délai de requête HTTP", | ||
"it": "Consentire di specificare se i certificati SSL auto-firmati/non validi vengono ignorati o meno (default deve ignorare fino ad ora)\nConsentire di specificare se viene utilizzato un \"insecure HTTP parser\" che consente anche implementazioni HTTP che non sono conformi alle specifiche\nConsentire di specificare il timeout della richiesta HTTP", | ||
"es": "Permitir especificar si los certificados SSL auto-firmados o inválidos son ignorados o no (por defecto es ignorar como hasta ahora)\nPermitir especificar si se utiliza un \"paraser HTTP seguro\" que también permite implementaciones HTTP que no cumplen con las especificaciones\nPermitir especificar el tiempo de solicitud HTTP", | ||
"pl": "Określenie, jeśli podpisywane certyfikaty SSL są ignorowane lub nie (obrona jest ignorowana jak do dziś)\nAllow do specyfikowania, jeśli używa się \"niebezpiecznego HTTP parser\", co umożliwia również implementacje HTTP, które nie są zgodne z specyfikacją\nAllow, aby zdefiniować HTTP żądanie czasu dostępu", | ||
"zh-cn": "请允许我具体说明,如果自我设计/自评的SSL证书遭到忽视或不(现在的意外情况是忽视)\n允许具体说明是否使用了“无保障的HTTP parser”,这也使不符合规格的技术转让中心得以实施。\n允许具体说明海贸总协定要求的时间" | ||
}, | ||
"1.1.8": { | ||
@@ -77,14 +89,2 @@ "en": "Check that a link is configured", | ||
"zh-cn": "如果正则表达式不匹配设置定义的替换值(或 null)" | ||
}, | ||
"1.1.2": { | ||
"en": "Fix initialization of new parser objects", | ||
"de": "Korrigieren Sie die Initialisierung neuer Parser-Objekte", | ||
"ru": "Исправить инициализацию новых объектов парсера", | ||
"pt": "Corrige a inicialização de novos objetos do analisador", | ||
"nl": "Initialisatie van nieuwe parser-objecten repareren", | ||
"fr": "Correction de l'initialisation des nouveaux objets d'analyseur", | ||
"it": "Correzione dell'inizializzazione di nuovi oggetti parser", | ||
"es": "Arreglar la inicialización de nuevos objetos del analizador.", | ||
"pl": "Napraw inicjalizację nowych obiektów parsera", | ||
"zh-cn": "修复新解析器对象的初始化" | ||
} | ||
@@ -139,2 +139,7 @@ }, | ||
], | ||
"globalDependencies": [ | ||
{ | ||
"admin": ">=3.0.0" | ||
} | ||
], | ||
"extIcon": "https://raw.githubusercontent.com/ioBroker/ioBroker.parser/master/admin/parser.png", | ||
@@ -152,4 +157,7 @@ "type": "logic", | ||
"native": { | ||
"pollInterval": "5000" | ||
"pollInterval": "5000", | ||
"requestTimeout": "60000", | ||
"acceptInvalidCertificates": true, | ||
"useInsecureHTTPParser": false | ||
} | ||
} |
32
main.js
@@ -8,3 +8,4 @@ /* jshint -W097 */// jshint strict:false | ||
const adapter = new utils.Adapter('parser'); | ||
let request; | ||
const https = require('https'); | ||
let axios; | ||
let path; | ||
@@ -140,2 +141,3 @@ let fs; | ||
function deletePoll(obj) { | ||
if (timers[obj.native.interval] === undefined) return; | ||
timers[obj.native.interval].count--; | ||
@@ -201,3 +203,3 @@ if (!timers[obj.native.interval].count) { | ||
if (obj.native.substituteOld) { | ||
adapter.log.warn('Cannot read link "' + obj.native.link + '": ' + error); | ||
adapter.log.info('Cannot read link "' + obj.native.link + '": ' + error); | ||
if (callback) { | ||
@@ -207,3 +209,3 @@ callback(); | ||
} else { | ||
adapter.log.error('Cannot read link "' + obj.native.link + '": ' + error); | ||
adapter.log.warn('Cannot read link "' + obj.native.link + '": ' + error); | ||
if (obj.value.q !== 0x82) { | ||
@@ -306,3 +308,3 @@ obj.value.q = 0x82; | ||
if (obj.native.substitute !== undefined) obj.value.val = obj.native.substitute; | ||
console.log('USe subs: "' + obj.native.substitute + '"'); | ||
console.log('Use substitution: "' + obj.native.substitute + '"'); | ||
@@ -325,16 +327,21 @@ adapter.setForeignState(obj._id, {val: obj.value.val, q: obj.value.q, ack: obj.value.ack}, callback); | ||
function readLink(link, callback) { | ||
async function readLink(link, callback) { | ||
if (link.match(/^https?:\/\//)) { | ||
request = request || require('request'); | ||
axios = axios || require('axios'); | ||
adapter.log.debug('Request URL: ' + link); | ||
try { | ||
request({ | ||
const res = await axios({ | ||
method: 'GET', | ||
url: link, | ||
rejectUnauthorized: false, | ||
timeout: 60000 | ||
}, (error, response, body) => callback(!body ? error || JSON.stringify(response) : null, body, link)); | ||
httpsAgent: new https.Agent({ | ||
rejectUnauthorized: adapter.config.acceptInvalidCertificates === false | ||
}), | ||
insecureHTTPParser: !!adapter.config.useInsecureHTTPParser, | ||
timeout: adapter.config.requestTimeout | ||
}); | ||
callback(res.status !== 200 ? res.statusText || JSON.stringify(res.status) : null, res.data, link) | ||
// (error, response, body) => callback(!body ? error || JSON.stringify(response) : null, body, link) | ||
} catch (err) { | ||
callback(err); | ||
callback(err.data ? err.data : err, null, link); | ||
} | ||
@@ -354,3 +361,3 @@ } else { | ||
} catch (e) { | ||
adapter.log.error('Cannot read file "' + link + '": ' + e); | ||
adapter.log.warn('Cannot read file "' + link + '": ' + e); | ||
callback(e, null, link); | ||
@@ -393,2 +400,3 @@ return; | ||
adapter.config.pollInterval = parseInt(adapter.config.pollInterval, 10) || 5000; | ||
adapter.config.requestTimeout = parseInt(adapter.config.requestTimeout, 10) || 60000; | ||
@@ -395,0 +403,0 @@ // read current existing objects (прочитать текущие существующие объекты) |
{ | ||
"name": "iobroker.parser", | ||
"version": "1.1.8", | ||
"version": "1.2.0", | ||
"description": "Parses web pages and files for values.", | ||
@@ -22,4 +22,4 @@ "author": { | ||
"dependencies": { | ||
"request": "^2.88.2", | ||
"@iobroker/adapter-core": "^2.6.0" | ||
"axios": "^0.27.2", | ||
"@iobroker/adapter-core": "^2.6.2" | ||
}, | ||
@@ -30,4 +30,4 @@ "devDependencies": { | ||
"@alcalzone/release-script-plugin-license": "^3.5.9", | ||
"gulp": "^4.0.2", | ||
"axios": "^0.27.2", | ||
"@iobroker/dev-server": "^0.5.0", | ||
"@iobroker/adapter-dev": "^1.0.1", | ||
"mocha": "^9.2.2", | ||
@@ -45,5 +45,6 @@ "chai": "^4.3.6" | ||
"release-minor": "release-script minor --yes", | ||
"release-major": "release-script major --yes" | ||
"release-major": "release-script major --yes", | ||
"translate": "translate-adapter" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -24,7 +24,17 @@ ![Logo](admin/parser.png) | ||
### 2. Table | ||
### 2. Request timeout | ||
Specify how long the adapter waits for an HTTP response when doing website queries | ||
### 3. Accept invalid certificates | ||
Specify if self-signed/invalid SSL/TLS certificates are accepted or declined when doing HTTPS requests | ||
### 4. Use insecure HTTP parser | ||
Specify to use an insecure HTTP parser that accepts invalid HTTP headers. This may allow interoperability with non-conformant HTTP implementations. | ||
Using the insecure parser should be avoided. | ||
### 5. Table | ||
Click the "Plus" button to add a new entry to the table. | ||
**Performance Note:** | ||
If you enter the same URL or filename more than once into different table rows, and if the values of the column "Interval" are the same, the content of the URL or filename will be retrieved only **once** and cached for proccesing multiple table rows matching URL/filename and Interval. This allows you to apply multiple regex (so multiple table rows) to a single URL or filename, without the need of retrieving the data multiple times from the source. | ||
If you enter the same URL or filename more than once into different table rows, and if the values of the column "Interval" are the same, the content of the URL or filename will be retrieved only **once** and cached for processing multiple table rows matching URL/filename and Interval. This allows you to apply multiple regex (so multiple table rows) to a single URL or filename, without the need of retrieving the data multiple times from the source. | ||
@@ -66,4 +76,2 @@ **Table fields:** | ||
## About Regular expressions (RegExp) | ||
@@ -98,2 +106,4 @@ Regular expressions are a powerful tool to parse and extract certain data from strings, and even more important: it allows to extract certain values/text from a given string (like from the HTML of a webpage, or text from a file) by applying rules. | ||
- (-?\d+) get number (both negative and positive numbers) | ||
- [+-]?([0-9]+.?[0-9]|.[0-9]+) get a number with decimal places (and . as decimal separator) | ||
- [+-]?([0-9]+,?[0-9]|,[0-9]+) get a number with decimal places (and , as decimal separator) | ||
@@ -113,2 +123,7 @@ ## Quality codes | ||
## Changelog | ||
### 1.2.0 (2022-09-12) | ||
* (Apollon77) Allow to specify if self-signed/invalid SSL certificates are ignored or not (default is to ignore as till now) | ||
* (Apollon77) Allow to specify if an "insecure HTTP parser" is used which also enables HTTP implementations that are not compliant to specifications | ||
* (Apollon77) Allow to specify the HTTP request timeout | ||
### 1.1.8 (2022-06-27) | ||
@@ -115,0 +130,0 @@ * (Apollon77) Check that a link is configured |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
207
1
380386
22
864
+ Addedaxios@^0.27.2
+ Addedaxios@0.27.2(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
- Removedrequest@^2.88.2
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)