Skip to content

Commit

Permalink
Change size limit to 4096. Upgrade to 1.0.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
golfvert committed Apr 10, 2023
1 parent a3fc02c commit 4bcd8da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docker-wis2globalbroker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ docker build --rm --no-cache \
--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \
--build-arg TAG_SUFFIX=default \
--file Dockerfile \
--tag golfvert/wis2globalbrokernodered:1.0.6 .
--tag golfvert/wis2globalbrokernodered:1.0.8 .
4 changes: 2 additions & 2 deletions flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
"type": "prometheus-metric-config",
"name": "wmo_wis2_gb_messages_invalid",
"help": "Number of invalid messages",
"labels": "host",
"labels": "centre_id,country",
"mtype": "counter"
},
{
Expand Down Expand Up @@ -1371,7 +1371,7 @@
"z": "3af82246.3634ae",
"g": "0e2c3f294eb753b6",
"name": "Check msg",
"func": "let message = msg.payload;\nlet topic = msg.topic;\nlet score = 100;\nlet errors = [];\nmsg.valid = true;\n\n// Check if topic is correct\n\nif ( ! ( topic.match('^origin/a.*$') || topic.match('^cache/a.*$') ) ) reject (\"topic in incorrect\");\n\n// Check existence of id\nconst id = message.id;\n\nif (id === undefined) reject (\"id is undefined\") ;\nelse {\n const valid_uuid = isUUID (id);\n if ( valid_uuid == false ) {\n score = score - 10;\n }\n}\n\nconst version = message.version;\nif (version === undefined || version != \"v04\") reject (\"version is undefined or not correct\");\n\nconst message_type = message.type;\nif (message_type === undefined || message_type != \"Feature\") reject (\"feature is undefined or not correct\");\n\nconst geometry = message.geometry;\nif (geometry === undefined ) reject (\"geometry is undefined\");\nelse {\n if ( geometry === null ) {}\n else {\n let geometry_type = geometry.type;\n if ( geometry_type == \"Point\") {\n let geometry_coord = geometry.coordinates;\n if ( isArray( geometry_coord ) ) {\n if ( geometry_coord.length > 3 ) reject (\"geometry coordinates length is not correct\");\n else {\n if ( ! ( ( typeof(geometry_coord[0]) == 'number' ) && ( geometry_coord[0] >= -180 ) && ( geometry_coord[0] <= 180 ) ) ) reject (\"geometry latitude is not correct\");\n if ( ! ( ( typeof(geometry_coord[1]) == 'number' ) && ( geometry_coord[1] >= -90 ) && ( geometry_coord[1] <= 90 ) ) ) reject (\"geometry latitude is not correct\");\n }\n }\n else reject (\"geometry is not an array\");\n }\n else {\n if ( geometry_type == \"Polygon\") {\n let geometry_coord = geometry.coordinates[0];\n let point;\n if ( isArray( geometry_coord ) ) {\n const first = geometry_coord[0];\n const last = geometry_coord[geometry_coord.length - 1];\n if ( (! isArray( first ) ) || ( !isArray( last ) ) || ( first[0] != last[0] ) || ( first[1] != last[1] ) ) reject (\"Polygon coordinates are not correct\");\n for (let i = 0; i < geometry_coord.length; i++) { \n point = geometry_coord[i];\n if ( isArray( point ) ) {\n if ( point.length != 2 ) reject (\"Point geometry coordinates length is not correct\");\n else {\n if ( ! ( ( typeof(point[0]) == 'number' ) && ( point[0] >= -180 ) && ( point[0] <= 180 ) ) ) reject (\"Point geometry latitude is not correct\");\n if ( ! ( ( typeof(point[1]) == 'number' ) && ( point[1] >= -90 ) && ( point[1] <= 90 ) ) ) reject (\"Point geometry latitude is not correct\");\n }\n }\n else reject (\"Point geometry is not an array\");\n }\n }\n else reject (\"geometry is not an array\");\n }\n else reject (\"geometry is not one of the agreed type (null, point, polygon\");\n }\n }\n}\n\nconst properties = message.properties;\nif (properties === undefined) reject (\"properties is undefined\");\nelse {\n \n const integrity = properties.integrity;\n if (integrity === undefined) score = score - 10;\n else { \n const method = integrity.method;\n if ( method === undefined) reject(\"Hashing method is undefined\");\n else { \n if ( method == \"MD5\" ) score = score - 10;\n else if ( method.match('^[sS][hH][aA]256|512$') === null ) reject(\"Hashing method is not correct\");\n }\n const value = integrity.value;\n if ( value === undefined) reject(\"value is undefined\");\n }\n \n const content = properties.content;\n if (content !== undefined) {\n const encoding = content.encoding;\n if ( encoding === undefined) reject(\"encoding is undefined\");\n else if ( encoding.match('^utf\\-8|base64$') === null ) reject(\"encoding is not correct\");\n const value_encoding = content.value;\n if ( value_encoding === undefined) reject(\"value within encoding is undefined\");\n const length = content.length;\n if ( length === undefined) reject(\"length within encoding is undefined\");\n else if ( length > 2048 ) reject(\"length exceeds the agreed value (2048)\");\n }\n \n const data_id = properties.data_id;\n if ( data_id === undefined) reject(\"data_id is undefined\");\n else if ( data_id.match(topic.substring(topic.indexOf(\"wis\"))) === null ) reject(\"data_id is not correct\");\n\n const pubtime = properties.pubtime;\n if ( pubtime === undefined) reject(\"pubtime is undefined\");\n else if ( pubtime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"pubtime is not RFC3339 compliant\");\n\n const datetime = properties.datetime;\n const start_datetime = properties.start_datetime;\n const end_datetime = properties.end_datetime;\n\n if ( datetime === undefined) {\n if ( start_datetime === undefined ) {\n if ( end_datetime === undefined ) score = score - 10;\n else reject(\"end_datetime is defined but start_datetime is not\") ;\n }\n else {\n if ( start_datetime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"start_datetime is not RFC3339 compliant\");\n else {\n if ( end_datetime === undefined ) reject(\"start_datetime is defined but end_datetime is not\");\n else if ( end_datetime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"end_datetime is not RFC3339 compliant\");\n }\n }\n }\n else {\n if ( start_datetime !== undefined || end_datetime !== undefined ) reject(\"datetime and start_datetime/end_datetime are both defined\");\n if ( datetime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"datetime is not RFC3339 compliant\");\n }\n}\n\nconst links = message.links;\nif (links === undefined) reject (\"links is undefined\");\nelse {\n if ( isArray( links ) ) {\n let href, rel, mime_type;\n let canonical_link = false;\n for (let i = 0; i < links.length; i++) { \n href = links[i].href;\n if ( href === undefined) reject (\"href is undefined\");\n if ( ! ( href.match('^http:\\/\\/.*$') || href.match('^https:\\/\\/.*$') || href.match('^sftp:\\/\\/.*$') || href.match('^ftp:\\/\\/.*$')) ) reject (\"Download protocol is incorrect\");\n if ( href.match('^http:\\/\\/.*$') || href.match('^ftp:\\/\\/.*$') ) score = score - 20;\n rel = links[i].rel;\n if ( rel === undefined) reject (\"rel is undefined\");\n if ( rel.match('^canonical$') ) canonical_link = true ;\n else if ( ! ( rel.match('^alternate|via$') ) ) reject (\"rel is not correct\");\n mime_type = links[i].type;\n if ( mime_type === undefined) reject (\"Mime-type is undefined\");\n }\n if ( canonical_link == false ) reject (\"canonical link is missing\");\n }\n else reject (\"links is not an array\");\n}\n\nmsg.score = score;\n\nif ( errors.length != 0 ) {\n let err = { \"errors\": errors };\n msg.payload._comment = err;\n} \n\n\nreturn msg;\n\nfunction isUUID ( uuid ) {\n let s = \"\" + uuid;\n s = s.match('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$');\n if (s === null) {\n return false;\n }\n return true;\n}\n\nfunction reject ( reason ) {\n errors.push(reason);\n score = 0;\n msg.score = score;\n msg.valid = false;\n return msg;\n}\n\nfunction isArray( myArray ) {\n return myArray.constructor.toString().indexOf(\"Array\") > -1;\n}\n",
"func": "let message = msg.payload;\nlet topic = msg.topic;\nlet score = 100;\nlet errors = [];\nmsg.valid = true;\n\n// Check if topic is correct\n\nif ( ! ( topic.match('^origin/a.*$') || topic.match('^cache/a.*$') ) ) reject (\"topic in incorrect\");\n\n// Check existence of id\nconst id = message.id;\n\nif (id === undefined) reject (\"id is undefined\") ;\nelse {\n const valid_uuid = isUUID (id);\n if ( valid_uuid == false ) {\n score = score - 10;\n }\n}\n\nconst version = message.version;\nif (version === undefined || version != \"v04\") reject (\"version is undefined or not correct\");\n\nconst message_type = message.type;\nif (message_type === undefined || message_type != \"Feature\") reject (\"feature is undefined or not correct\");\n\nconst geometry = message.geometry;\nif (geometry === undefined ) reject (\"geometry is undefined\");\nelse {\n if ( geometry === null ) {}\n else {\n let geometry_type = geometry.type;\n if ( geometry_type == \"Point\") {\n let geometry_coord = geometry.coordinates;\n if ( isArray( geometry_coord ) ) {\n if ( geometry_coord.length > 3 ) reject (\"geometry coordinates length is not correct\");\n else {\n if ( ! ( ( typeof(geometry_coord[0]) == 'number' ) && ( geometry_coord[0] >= -180 ) && ( geometry_coord[0] <= 180 ) ) ) reject (\"geometry latitude is not correct\");\n if ( ! ( ( typeof(geometry_coord[1]) == 'number' ) && ( geometry_coord[1] >= -90 ) && ( geometry_coord[1] <= 90 ) ) ) reject (\"geometry latitude is not correct\");\n }\n }\n else reject (\"geometry is not an array\");\n }\n else {\n if ( geometry_type == \"Polygon\") {\n let geometry_coord = geometry.coordinates[0];\n let point;\n if ( isArray( geometry_coord ) ) {\n const first = geometry_coord[0];\n const last = geometry_coord[geometry_coord.length - 1];\n if ( (! isArray( first ) ) || ( !isArray( last ) ) || ( first[0] != last[0] ) || ( first[1] != last[1] ) ) reject (\"Polygon coordinates are not correct\");\n for (let i = 0; i < geometry_coord.length; i++) { \n point = geometry_coord[i];\n if ( isArray( point ) ) {\n if ( point.length != 2 ) reject (\"Point geometry coordinates length is not correct\");\n else {\n if ( ! ( ( typeof(point[0]) == 'number' ) && ( point[0] >= -180 ) && ( point[0] <= 180 ) ) ) reject (\"Point geometry latitude is not correct\");\n if ( ! ( ( typeof(point[1]) == 'number' ) && ( point[1] >= -90 ) && ( point[1] <= 90 ) ) ) reject (\"Point geometry latitude is not correct\");\n }\n }\n else reject (\"Point geometry is not an array\");\n }\n }\n else reject (\"geometry is not an array\");\n }\n else reject (\"geometry is not one of the agreed type (null, point, polygon\");\n }\n }\n}\n\nconst properties = message.properties;\nif (properties === undefined) reject (\"properties is undefined\");\nelse {\n \n const integrity = properties.integrity;\n if (integrity === undefined) score = score - 10;\n else { \n const method = integrity.method;\n if ( method === undefined) reject(\"Hashing method is undefined\");\n else { \n if ( method == \"MD5\" ) score = score - 10;\n else if ( method.match('^[sS][hH][aA]256|512$') === null ) reject(\"Hashing method is not correct\");\n }\n const value = integrity.value;\n if ( value === undefined) reject(\"value is undefined\");\n }\n \n const content = properties.content;\n if (content !== undefined) {\n const encoding = content.encoding;\n if ( encoding === undefined) reject(\"encoding is undefined\");\n else if ( encoding.match('^utf\\-8|base64$') === null ) reject(\"encoding is not correct\");\n const value_encoding = content.value;\n if ( value_encoding === undefined) reject(\"value within encoding is undefined\");\n const size = content.size;\n if ( size === undefined) reject(\"size within encoding is undefined\");\n else if ( size > 8192 ) reject(\"length exceeds the agreed value (4096)\");\n }\n \n const data_id = properties.data_id;\n if ( data_id === undefined) reject(\"data_id is undefined\");\n else if ( data_id.match(topic.substring(topic.indexOf(\"wis\"))) === null ) reject(\"data_id is not correct\");\n\n const pubtime = properties.pubtime;\n if ( pubtime === undefined) reject(\"pubtime is undefined\");\n else if ( pubtime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"pubtime is not RFC3339 compliant\");\n\n const datetime = properties.datetime;\n const start_datetime = properties.start_datetime;\n const end_datetime = properties.end_datetime;\n\n if ( datetime === undefined) {\n if ( start_datetime === undefined ) {\n if ( end_datetime === undefined ) score = score - 10;\n else reject(\"end_datetime is defined but start_datetime is not\") ;\n }\n else {\n if ( start_datetime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"start_datetime is not RFC3339 compliant\");\n else {\n if ( end_datetime === undefined ) reject(\"start_datetime is defined but end_datetime is not\");\n else if ( end_datetime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"end_datetime is not RFC3339 compliant\");\n }\n }\n }\n else {\n if ( start_datetime !== undefined || end_datetime !== undefined ) reject(\"datetime and start_datetime/end_datetime are both defined\");\n if ( datetime.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}[t|T| ][0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]*[Z|z]$') === null ) reject(\"datetime is not RFC3339 compliant\");\n }\n}\n\nconst links = message.links;\nif (links === undefined) reject (\"links is undefined\");\nelse {\n if ( isArray( links ) ) {\n let href, rel, mime_type;\n let canonical_link = false;\n for (let i = 0; i < links.length; i++) { \n href = links[i].href;\n if ( href === undefined) reject (\"href is undefined\");\n if ( ! ( href.match('^http:\\/\\/.*$') || href.match('^https:\\/\\/.*$') || href.match('^sftp:\\/\\/.*$') || href.match('^ftp:\\/\\/.*$')) ) reject (\"Download protocol is incorrect\");\n if ( href.match('^http:\\/\\/.*$') || href.match('^ftp:\\/\\/.*$') ) score = score - 20;\n rel = links[i].rel;\n if ( rel === undefined) reject (\"rel is undefined\");\n if ( rel.match('^canonical$') ) canonical_link = true ;\n else if ( ! ( rel.match('^alternate|via$') ) ) reject (\"rel is not correct\");\n mime_type = links[i].type;\n if ( mime_type === undefined) reject (\"Mime-type is undefined\");\n }\n if ( canonical_link == false ) reject (\"canonical link is missing\");\n }\n else reject (\"links is not an array\");\n}\n\nmsg.score = score;\n\nif ( errors.length != 0 ) {\n let err = { \"errors\": errors };\n msg.payload._comment = err;\n} \n\n\nreturn msg;\n\nfunction isUUID ( uuid ) {\n let s = \"\" + uuid;\n s = s.match('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$');\n if (s === null) {\n return false;\n }\n return true;\n}\n\nfunction reject ( reason ) {\n errors.push(reason);\n score = 0;\n msg.score = score;\n msg.valid = false;\n return msg;\n}\n\nfunction isArray( myArray ) {\n return myArray.constructor.toString().indexOf(\"Array\") > -1;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
Expand Down
3 changes: 2 additions & 1 deletion known_hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ ssh-keygen -l -f ${known_hosts_file} | sort > "$fingerprints"

diff - "$fingerprints" <<EOF
2048 SHA256:ROQFvPThGrW4RuWLoL9tq9I9zJ42fK4XywyRtbOz/EQ gitlab.com (RSA)
2048 SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 github.com (RSA)
2048 SHA256:ohD8VZEXGWo6Ez8GSEJQ9WpafgLFsOfLOtGGQCQo6Og ssh.dev.azure.com (RSA)
2048 SHA256:ohD8VZEXGWo6Ez8GSEJQ9WpafgLFsOfLOtGGQCQo6Og vs-ssh.visualstudio.com (RSA)
2048 SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A bitbucket.org (RSA)
Expand All @@ -54,6 +53,7 @@ diff - "$fingerprints" <<EOF
256 SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw gitlab.com (ECDSA)
256 SHA256:eUXGGm1YGsMAS7vkcx6JOJdOGHPem5gQp4taiCfCLB8 gitlab.com (ED25519)
256 SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM github.com (ECDSA)
3072 SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s github.com (RSA)
EOF

}
Expand All @@ -71,3 +71,4 @@ until ${ok}; do
fi
sleep ${wait}
done

0 comments on commit 4bcd8da

Please sign in to comment.