Skip to content

Commit 887e1b3

Browse files
Merge pull request telefonicaid#4654 from telefonicaid/hardening/cjexl-0.5.0
FIX upgarde cjexl to 0.5.0
2 parents 174ac1d + 254f263 commit 887e1b3

File tree

6 files changed

+241
-10
lines changed

6 files changed

+241
-10
lines changed

CHANGES_NEXT_RELEASE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
- Hardening: upgrade microhttpd dependency from 0.9.76 to 1.0.1
88
- Hardening: upgrade libmosquitto dependency from 2.0.15 to 2.0.20
99
- Hardening: upgrade libmongoc dependency from 1.24.3 to 1.29.0
10+
- Upgrade cjexl version from 0.4.0 to 0.5.0 (new transformations: arrMax, arrMin, arrMed, arrSort and arrReverse )
1011
- Upgrade Debian version from 12.6 to 12.9 in Dockerfile

ci/deb/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ rm -Rf /tmp/builder || true && mkdir -p /tmp/builder/{db1,db2,db,bu}
175175
if [ -z "${REPO_ACCESS_TOKEN}" ]; then
176176
echo "Builder: no REPO_ACCESS_TOKEN, skipping cjexl lib download"
177177
else
178-
bash /opt/fiware-orion/get_cjexl.sh 0.4.0 $REPO_ACCESS_TOKEN
178+
bash /opt/fiware-orion/get_cjexl.sh 0.5.0 $REPO_ACCESS_TOKEN
179179
fi
180180

181181
if [ -n "${branch}" ]; then

doc/manuals/orion-api.md

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@
109109
- [`keys`](#keys)
110110
- [`arrSum`](#arrsum)
111111
- [`arrAvg`](#arravg)
112+
- [`arrMax`](#arrmax)
113+
- [`arrMin`](#arrmin)
114+
- [`arrMed`](#arrmed)
115+
- [`arrSort`](#arrsort)
116+
- [`arrReverse`](#arrreverse)
112117
- [`now`](#now)
113118
- [`toIsoString`](#toisostring)
114119
- [`getTime`](#gettime)
@@ -3155,10 +3160,16 @@ results in
31553160

31563161
#### arrSum
31573162

3158-
Returns the sum of the elements of an array (or `null` if the input in an array or the array contains some not numberic item).
3163+
Returns the sum of the elements of an array.
31593164

31603165
Extra arguments: none
31613166

3167+
This transformation will return `null` in the following cases:
3168+
3169+
* The input is not an array
3170+
* The array is empty
3171+
* The array containts some non numeric item
3172+
31623173
Example (being context `{"c": [1, 5]}`):
31633174

31643175
```
@@ -3173,10 +3184,16 @@ results in
31733184

31743185
#### arrAvg
31753186

3176-
Returns the average of the elements of an array (or `null` if the input in an array or the array contains some not numberic item).
3187+
Returns the average of the elements of an array
31773188

31783189
Extra arguments: none
31793190

3191+
This transformation will return `null` in the following cases:
3192+
3193+
* The input is not an array
3194+
* The array is empty
3195+
* The array containts some non numeric item
3196+
31803197
Example (being context `{"c": [1, 5]}`):
31813198

31823199
```
@@ -3189,6 +3206,135 @@ results in
31893206
3
31903207
```
31913208

3209+
#### arrMax
3210+
3211+
Returns the maximum of the elements of an array
3212+
3213+
Extra arguments: none
3214+
3215+
This transformation will return `null` in the following cases:
3216+
3217+
* The input is not an array
3218+
* The array is empty
3219+
* The array containts some non numeric item
3220+
3221+
Example (being context `{"c": [1, 5]}`):
3222+
3223+
```
3224+
c|arrMax
3225+
```
3226+
3227+
results in
3228+
3229+
```
3230+
5
3231+
```
3232+
3233+
#### arrMin
3234+
3235+
Returns the minimum of the elements of an array
3236+
3237+
Extra arguments: none
3238+
3239+
This transformation will return `null` in the following cases:
3240+
3241+
* The input is not an array
3242+
* The array is empty
3243+
* The array containts some non numeric item
3244+
3245+
Example (being context `{"c": [1, 5]}`):
3246+
3247+
```
3248+
c|arrMin
3249+
```
3250+
3251+
results in
3252+
3253+
```
3254+
1
3255+
```
3256+
3257+
#### arrMed
3258+
3259+
Returns the median value of the elements of an array
3260+
3261+
Extra arguments: none
3262+
3263+
This transformation will return `null` in the following cases:
3264+
3265+
* The input is not an array
3266+
* The array is empty
3267+
* The array containts some non numeric item
3268+
3269+
Example (being context `{"c": [1, 3, 3, 6, 7, 8, 9]}`):
3270+
3271+
```
3272+
c|arrMed
3273+
```
3274+
3275+
results in
3276+
3277+
```
3278+
6
3279+
```
3280+
3281+
Example (being context `{"c": [1, 2, 3, 4, 5, 6, 8, 9]}`):
3282+
3283+
```
3284+
c|arrMed
3285+
```
3286+
3287+
results in
3288+
3289+
```
3290+
4.5
3291+
```
3292+
3293+
#### arrSort
3294+
3295+
Returns the sorted version of the array used as input
3296+
3297+
Extra arguments: none
3298+
3299+
This transformation will return `null` in the following cases:
3300+
3301+
* The input is not an array
3302+
* The array containts some non numeric item
3303+
3304+
Example (being context `{"c": [3, 1, 3, 9, 7, 8, 6]}`):
3305+
3306+
```
3307+
c|arrSort
3308+
```
3309+
3310+
results in
3311+
3312+
```
3313+
[1, 3, 3, 6, 7, 8, 9]
3314+
```
3315+
3316+
#### arrReverse
3317+
3318+
Returns the the reserved version of the array used as input
3319+
3320+
Extra arguments: none
3321+
3322+
This transformation will return `null` in the following cases:
3323+
3324+
* The input is not an array
3325+
3326+
Example (being context `{"c": [3, 1, 3, 9, 7, 8, 6]}`):
3327+
3328+
```
3329+
c|arrReverse
3330+
```
3331+
3332+
results in
3333+
3334+
```
3335+
[6, 8, 7, 9, 3, 1, 3]
3336+
```
3337+
31923338
#### now
31933339

31943340
Returns the current time (plus a number of seconds specified as argument) as seconds since Unix epoch time.

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ RUN --mount=type=secret,id=repo_token,dst=/run/secrets/repo_token \
102102
git clone https://github.com/${GIT_NAME}/fiware-orion && \
103103
cd fiware-orion && \
104104
git checkout ${GIT_REV_ORION} && \
105-
bash get_cjexl.sh 0.4.0 $(cat /run/secrets/repo_token) && \
105+
bash get_cjexl.sh 0.5.0 $(cat /run/secrets/repo_token) && \
106106
make && \
107107
make install && \
108108
# reduce size of installed binaries

docker/Dockerfile.alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ RUN --mount=type=secret,id=repo_token,dst=/run/secrets/repo_token \
108108
git clone https://github.com/${GIT_NAME}/fiware-orion && \
109109
cd fiware-orion && \
110110
git checkout ${GIT_REV_ORION} && \
111-
bash get_cjexl.sh 0.4.0 $(cat /run/secrets/repo_token) && \
111+
bash get_cjexl.sh 0.5.0 $(cat /run/secrets/repo_token) && \
112112
# patch bash and mktemp statement in build script, as in alpine is slightly different
113113
sed -i 's/mktemp \/tmp\/compileInfo.h.XXXX/mktemp/g' scripts/build/compileInfo.sh && \
114114
sed -i 's/bash/ash/g' scripts/build/compileInfo.sh && \

test/functionalTest/cases/4004_jexl_expressions_in_subs/jexl_transformation_full.test

Lines changed: 89 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ accumulatorStart --pretty-print
3333

3434
#
3535
# 01. Create custom sub using all transformations
36-
# 02. Create entity E1 with A to AD attributes
36+
# 02. Create entity E1 with A to AL attributes
3737
# 03. Dump accumulator and see expected notification
3838
#
3939

@@ -84,7 +84,12 @@ payload='{
8484
"AD",
8585
"AE",
8686
"AF",
87-
"AG"
87+
"AG",
88+
"AH",
89+
"AI",
90+
"AJ",
91+
"AK",
92+
"AL"
8893
],
8994
"httpCustom": {
9095
"url": "http://127.0.0.1:'${LISTENER_PORT}'/notify",
@@ -220,6 +225,26 @@ payload='{
220225
"AG": {
221226
"type": "Number",
222227
"value": "${AG|getTime}"
228+
},
229+
"AH": {
230+
"type": "Number",
231+
"value": "${AH|arrMin}"
232+
},
233+
"AI": {
234+
"type": "Number",
235+
"value": "${AI|arrMax}"
236+
},
237+
"AJ": {
238+
"type": "Number",
239+
"value": "${AJ|arrMed}"
240+
},
241+
"AK": {
242+
"type": "Number",
243+
"value": "${AK|arrSort}"
244+
},
245+
"AL": {
246+
"type": "Number",
247+
"value": "${AL|arrReverse}"
223248
}
224249
}
225250
}
@@ -230,7 +255,7 @@ echo
230255
echo
231256

232257

233-
echo "02. Create entity E1 with A to AD attributes"
258+
echo "02. Create entity E1 with A to AL attributes"
234259
echo "============================================"
235260
payload='{
236261
"id": "E1",
@@ -371,6 +396,26 @@ payload='{
371396
"AG": {
372397
"type": "Number",
373398
"value": "1979-11-13T18:01:14+00:00"
399+
},
400+
"AH": {
401+
"type": "StructuredValue",
402+
"value": [1, 2, 3]
403+
},
404+
"AI": {
405+
"type": "StructuredValue",
406+
"value": [1, 2, 3]
407+
},
408+
"AJ": {
409+
"type": "StructuredValue",
410+
"value": [3, 1, 3, 9, 7, 8, 6]
411+
},
412+
"AK": {
413+
"type": "StructuredValue",
414+
"value": [3, 1, 3, 9, 7, 8, 6]
415+
},
416+
"AL": {
417+
"type": "StructuredValue",
418+
"value": [1, 2, 3, "foo", true]
374419
}
375420
}'
376421
orionCurl --url /v2/entities --payload "$payload"
@@ -396,7 +441,7 @@ Content-Length: 0
396441

397442

398443

399-
02. Create entity E1 with A to AD attributes
444+
02. Create entity E1 with A to AL attributes
400445
============================================
401446
HTTP/1.1 201 Created
402447
Date: REGEX(.*)
@@ -410,7 +455,7 @@ Content-Length: 0
410455
==================================================
411456
POST http://127.0.0.1:REGEX(\d+)/notify
412457
Fiware-Servicepath: /
413-
Content-Length: 1809
458+
Content-Length: 2075
414459
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
415460
Ngsiv2-Attrsformat: normalized
416461
Host: 127.0.0.1:REGEX(\d+)
@@ -464,6 +509,45 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1
464509
"type": "Number",
465510
"value": 311364074
466511
},
512+
"AH": {
513+
"metadata": {},
514+
"type": "Number",
515+
"value": 1
516+
},
517+
"AI": {
518+
"metadata": {},
519+
"type": "Number",
520+
"value": 3
521+
},
522+
"AJ": {
523+
"metadata": {},
524+
"type": "Number",
525+
"value": 6
526+
},
527+
"AK": {
528+
"metadata": {},
529+
"type": "Number",
530+
"value": [
531+
1,
532+
3,
533+
3,
534+
6,
535+
7,
536+
8,
537+
9
538+
]
539+
},
540+
"AL": {
541+
"metadata": {},
542+
"type": "Number",
543+
"value": [
544+
true,
545+
"foo",
546+
3,
547+
2,
548+
1
549+
]
550+
},
467551
"B": {
468552
"metadata": {},
469553
"type": "Text",

0 commit comments

Comments
 (0)