durable_rules 2.0.22 → 2.0.27
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.
- checksums.yaml +4 -4
- data/librb/durable.rb +6 -3
- data/src/rules/events.c +57 -3
- data/src/rules/json.c +6 -0
- data/src/rules/regex.c +19 -8
- data/src/rules/rete.c +1 -0
- data/src/rules/rete.h +1 -1
- data/src/rules/rules.h +4 -1
- data/src/rules/state.c +11 -2
- data/src/rules/state.h +7 -5
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 718b325b66f1671880337e82b9c0733e69d86710
         | 
| 4 | 
            +
              data.tar.gz: 8b76eef7e27b274415db71c511ceab15b982b7ad
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ee85bce7113af542f36608b2bec47e3f00397f8c5bff5b6ed123b55512d5504f40a151df58b04d7f2970ae9a814c0625c8831e41194fe1433a7b7e8292638b28
         | 
| 7 | 
            +
              data.tar.gz: f4cee04af0c0b941831cdc9fbf0ef2df5403c39c05fc522bd440653ab322b96fad08b051aa4047972a9f3cd77ff3d9ea2f0a4dc8a0c69ba69f96389e46a0ccde
         | 
    
        data/librb/durable.rb
    CHANGED
    
    
    
        data/src/rules/events.c
    CHANGED
    
    | @@ -486,13 +486,67 @@ static unsigned int reduceExpression(ruleset *tree, | |
| 486 486 |  | 
| 487 487 | 
             
                if (currentExpression->right.type == JSON_REGEX || currentExpression->right.type == JSON_IREGEX) {
         | 
| 488 488 | 
             
                    targetProperty->type = JSON_BOOL;
         | 
| 489 | 
            +
                    targetProperty->value.b = 0;
         | 
| 490 | 
            +
             | 
| 491 | 
            +
                    char *leftString = "";
         | 
| 492 | 
            +
                    unsigned short leftLength = 0;
         | 
| 493 | 
            +
                    switch(leftProperty->type) {
         | 
| 494 | 
            +
                        case JSON_INT:
         | 
| 495 | 
            +
                            {
         | 
| 496 | 
            +
                #ifdef _WIN32
         | 
| 497 | 
            +
                                leftString = (char *)_alloca(sizeof(char)*(MAX_INT_LENGTH + 1));
         | 
| 498 | 
            +
                                sprintf_s(leftString, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", leftProperty->value.i);
         | 
| 499 | 
            +
                #else
         | 
| 500 | 
            +
                                char newString[MAX_INT_LENGTH + 1];
         | 
| 501 | 
            +
                                leftString = newString;
         | 
| 502 | 
            +
                                snprintf(leftString, sizeof(char)*(MAX_INT_LENGTH + 1), "%lld", leftProperty->value.i);
         | 
| 503 | 
            +
                #endif         
         | 
| 504 | 
            +
                                leftLength = strlen(leftString);
         | 
| 505 | 
            +
                                break;
         | 
| 506 | 
            +
                            }
         | 
| 507 | 
            +
                        case JSON_DOUBLE:
         | 
| 508 | 
            +
                            {
         | 
| 509 | 
            +
                #ifdef _WIN32
         | 
| 510 | 
            +
                                leftString = (char *)_alloca(sizeof(char)*(MAX_DOUBLE_LENGTH + 1));
         | 
| 511 | 
            +
                                sprintf_s(leftString, sizeof(char)*(MAX_DOUBLE_LENGTH + 1), "%f", leftProperty->value.d);
         | 
| 512 | 
            +
                #else
         | 
| 513 | 
            +
                                char newString[MAX_DOUBLE_LENGTH + 1];
         | 
| 514 | 
            +
                                leftString = newString;
         | 
| 515 | 
            +
                                snprintf(leftString, sizeof(char)*(MAX_DOUBLE_LENGTH + 1), "%f", leftProperty->value.d);
         | 
| 516 | 
            +
                #endif         
         | 
| 517 | 
            +
                                leftLength = strlen(leftString);
         | 
| 518 | 
            +
                                break;
         | 
| 519 | 
            +
                            }
         | 
| 520 | 
            +
                        case JSON_BOOL:
         | 
| 521 | 
            +
                            if (leftProperty->value.b) {
         | 
| 522 | 
            +
                                leftString = "true";
         | 
| 523 | 
            +
                                leftLength = 4;
         | 
| 524 | 
            +
                            }
         | 
| 525 | 
            +
                            else {
         | 
| 526 | 
            +
                                leftString = "false";
         | 
| 527 | 
            +
                                leftLength = 5;
         | 
| 528 | 
            +
                            }
         | 
| 529 | 
            +
             | 
| 530 | 
            +
                            break;
         | 
| 531 | 
            +
                        case JSON_NIL:
         | 
| 532 | 
            +
                            leftString = "nil";
         | 
| 533 | 
            +
                            leftLength = 3;
         | 
| 534 | 
            +
                            break;
         | 
| 535 | 
            +
                        case JSON_STRING:
         | 
| 536 | 
            +
                            leftString = leftProperty->value.s;
         | 
| 537 | 
            +
                            leftLength = leftProperty->valueLength;
         | 
| 538 | 
            +
                            break;
         | 
| 539 | 
            +
                    }
         | 
| 540 | 
            +
             | 
| 489 541 | 
             
                    targetProperty->value.b = evaluateRegex(tree,
         | 
| 490 | 
            -
                                                             | 
| 491 | 
            -
                                                             | 
| 542 | 
            +
                                                            leftString, 
         | 
| 543 | 
            +
                                                            leftLength, 
         | 
| 492 544 | 
             
                                                            (currentExpression->right.type == JSON_REGEX) ? 0 : 1,
         | 
| 493 545 | 
             
                                                            currentExpression->right.value.regex.vocabularyLength,
         | 
| 494 546 | 
             
                                                            currentExpression->right.value.regex.statesLength,
         | 
| 495 547 | 
             
                                                            currentExpression->right.value.regex.stateMachineOffset);
         | 
| 548 | 
            +
                    
         | 
| 549 | 
            +
             | 
| 496 550 | 
             
                    return RULES_OK;
         | 
| 497 551 | 
             
                }
         | 
| 498 552 |  | 
| @@ -1533,7 +1587,7 @@ static unsigned int isArrayMatch(ruleset *tree, | |
| 1533 1587 | 
             
                                             jsonProperty *currentProperty,
         | 
| 1534 1588 | 
             
                                             alpha *arrayAlpha,
         | 
| 1535 1589 | 
             
                                             unsigned char *propertyMatch) {
         | 
| 1536 | 
            -
                
         | 
| 1590 | 
            +
                *propertyMatch = 0;
         | 
| 1537 1591 | 
             
                unsigned int result = RULES_OK;
         | 
| 1538 1592 | 
             
                if (currentProperty->type != JSON_ARRAY) {
         | 
| 1539 1593 | 
             
                    return RULES_OK;
         | 
    
        data/src/rules/json.c
    CHANGED
    
    | @@ -132,6 +132,12 @@ unsigned int readNextArrayValue(char *start, char **first, char **last, unsigned | |
| 132 132 | 
             
                            }
         | 
| 133 133 | 
             
                            break;
         | 
| 134 134 | 
             
                        case ST_OBJECT_PROP_VAL:
         | 
| 135 | 
            +
                            if (start[0] == ']') {
         | 
| 136 | 
            +
                                *first = start;
         | 
| 137 | 
            +
                                *last = start;
         | 
| 138 | 
            +
                                return PARSE_END;    
         | 
| 139 | 
            +
                            }
         | 
| 140 | 
            +
                            
         | 
| 135 141 | 
             
                            return getValue(start, first, last, type);
         | 
| 136 142 | 
             
                            break;
         | 
| 137 143 | 
             
                    }
         | 
    
        data/src/rules/regex.c
    CHANGED
    
    | @@ -23,6 +23,7 @@ | |
| 23 23 | 
             
            #define MAX_SET 8192
         | 
| 24 24 | 
             
            #define MAX_LIST 1024
         | 
| 25 25 | 
             
            #define MAX_INTERVAL 100
         | 
| 26 | 
            +
            #define MAX_REFCOUNT 1000
         | 
| 26 27 |  | 
| 27 28 |  | 
| 28 29 | 
             
            #define CREATE_QUEUE(type) \
         | 
| @@ -597,10 +598,6 @@ static unsigned int linkStates(state *previousState, | |
| 597 598 | 
             
                previousState->transitions[previousState->transitionsLength].next = nextState;
         | 
| 598 599 | 
             
                ++previousState->transitionsLength;
         | 
| 599 600 | 
             
                ++nextState->refCount;
         | 
| 600 | 
            -
                if (previousState->transitionsLength == MAX_TRANSITIONS) {
         | 
| 601 | 
            -
                    return ERR_REGEX_MAX_TRANSITIONS;
         | 
| 602 | 
            -
                }
         | 
| 603 | 
            -
             | 
| 604 601 | 
             
                return RULES_OK;
         | 
| 605 602 | 
             
            }
         | 
| 606 603 |  | 
| @@ -852,10 +849,18 @@ static unsigned int validateGraph(char **first, char *last) { | |
| 852 849 | 
             
                    switch (currentToken.type) {
         | 
| 853 850 | 
             
                        case REGEX_SYMBOL:
         | 
| 854 851 | 
             
                        case REGEX_UNION:
         | 
| 855 | 
            -
                        case REGEX_STAR:
         | 
| 856 852 | 
             
                        case REGEX_PLUS:
         | 
| 857 | 
            -
                        case REGEX_QUESTION:
         | 
| 858 853 | 
             
                            break;
         | 
| 854 | 
            +
                        case REGEX_STAR:
         | 
| 855 | 
            +
                        case REGEX_QUESTION:
         | 
| 856 | 
            +
                        {
         | 
| 857 | 
            +
                            char *nextFirst = *first; 
         | 
| 858 | 
            +
                            token nextToken;
         | 
| 859 | 
            +
                            unsigned int nextResult = readNextToken(&nextFirst, last, &nextToken); 
         | 
| 860 | 
            +
                            if (nextResult == REGEX_PARSE_OK && nextToken.type == REGEX_STAR) {
         | 
| 861 | 
            +
                                return ERR_REGEX_INVALID;
         | 
| 862 | 
            +
                            }
         | 
| 863 | 
            +
                        }
         | 
| 859 864 | 
             
                        case REGEX_REGEX:
         | 
| 860 865 | 
             
                            result = validateGraph(first, last);
         | 
| 861 866 | 
             
                            if (result != REGEX_PARSE_OK) {
         | 
| @@ -1141,7 +1146,7 @@ static unsigned int transformToDFA(state *nfa, | |
| 1141 1146 | 
             
                        }
         | 
| 1142 1147 | 
             
                    }
         | 
| 1143 1148 |  | 
| 1144 | 
            -
                    DEQUEUE(¤tState); | 
| 1149 | 
            +
                    DEQUEUE(¤tState);
         | 
| 1145 1150 | 
             
                }
         | 
| 1146 1151 |  | 
| 1147 1152 | 
             
                return RULES_OK;
         | 
| @@ -1255,7 +1260,7 @@ static unsigned int packGraph(state *start, | |
| 1255 1260 | 
             
                    for (int i = 0; i < currentState->transitionsLength; ++ i) {
         | 
| 1256 1261 | 
             
                        transition *currentTransition = ¤tState->transitions[i];
         | 
| 1257 1262 | 
             
                        unsigned int currentTransitionSymbol = currentTransition->symbol;
         | 
| 1258 | 
            -
                        if (caseInsensitive) {
         | 
| 1263 | 
            +
                        if (caseInsensitive && currentTransitionSymbol != REGEX_DOT) {
         | 
| 1259 1264 | 
             
                            currentTransitionSymbol = tolower(currentTransitionSymbol);
         | 
| 1260 1265 | 
             
                        }
         | 
| 1261 1266 |  | 
| @@ -1343,6 +1348,12 @@ unsigned int compileRegex(void *tree, | |
| 1343 1348 | 
             
                if (result != RULES_OK) {
         | 
| 1344 1349 | 
             
                    return result;
         | 
| 1345 1350 | 
             
                }
         | 
| 1351 | 
            +
             | 
| 1352 | 
            +
                if (!*vocabularyLength || !*statesLength) {
         | 
| 1353 | 
            +
                    return ERR_REGEX_INVALID;
         | 
| 1354 | 
            +
                }
         | 
| 1355 | 
            +
             | 
| 1356 | 
            +
             | 
| 1346 1357 | 
             
                void *newStateMachine;    
         | 
| 1347 1358 | 
             
                result = storeRegexStateMachine((ruleset *)tree, 
         | 
| 1348 1359 | 
             
                                                *vocabularyLength, 
         | 
    
        data/src/rules/rete.c
    CHANGED
    
    
    
        data/src/rules/rete.h
    CHANGED
    
    
    
        data/src/rules/rules.h
    CHANGED
    
    | @@ -33,6 +33,8 @@ | |
| 33 33 | 
             
            #define ERR_NO_ACTION_AVAILABLE 310
         | 
| 34 34 | 
             
            #define ERR_PROPERTY_NOT_FOUND 311
         | 
| 35 35 | 
             
            #define ERR_OPERATION_NOT_SUPPORTED 312
         | 
| 36 | 
            +
            #define ERR_EVENT_MAX_OBJECT_SIZE 313
         | 
| 37 | 
            +
            #define ERR_EVENT_MAX_OBJECT_PROPERTY_SIZE 314
         | 
| 36 38 | 
             
            #define ERR_PARSE_REGEX 501
         | 
| 37 39 | 
             
            #define ERR_REGEX_MAX_TRANSITIONS 502
         | 
| 38 40 | 
             
            #define ERR_REGEX_MAX_STATES 503
         | 
| @@ -40,6 +42,7 @@ | |
| 40 42 | 
             
            #define ERR_REGEX_LIST_FULL 505
         | 
| 41 43 | 
             
            #define ERR_REGEX_SET_FULL 506
         | 
| 42 44 | 
             
            #define ERR_REGEX_CONFLICT 507
         | 
| 45 | 
            +
            #define ERR_REGEX_INVALID 508
         | 
| 43 46 |  | 
| 44 47 | 
             
            #define NEXT_BUCKET_LENGTH 512
         | 
| 45 48 | 
             
            #define NEXT_LIST_LENGTH 128
         | 
| @@ -63,7 +66,7 @@ typedef struct handleEntry { | |
| 63 66 | 
             
                unsigned int nextEmptyEntry;
         | 
| 64 67 | 
             
            } handleEntry;
         | 
| 65 68 |  | 
| 66 | 
            -
            handleEntry handleEntries[MAX_HANDLES];
         | 
| 69 | 
            +
            extern handleEntry handleEntries[MAX_HANDLES];
         | 
| 67 70 | 
             
            extern unsigned int firstEmptyEntry;
         | 
| 68 71 | 
             
            extern unsigned int lastEmptyEntry;
         | 
| 69 72 | 
             
            extern char entriesInitialized;
         | 
    
        data/src/rules/state.c
    CHANGED
    
    | @@ -1378,8 +1378,17 @@ unsigned int getObjectProperty(jsonObject *jo, | |
| 1378 1378 | 
             
            unsigned int setObjectProperty(jsonObject *jo, 
         | 
| 1379 1379 | 
             
                                           unsigned int hash, 
         | 
| 1380 1380 | 
             
                                           unsigned char type, 
         | 
| 1381 | 
            -
                                           unsigned  | 
| 1382 | 
            -
                                           unsigned  | 
| 1381 | 
            +
                                           unsigned int valueOffset, 
         | 
| 1382 | 
            +
                                           unsigned int valueLength) {
         | 
| 1383 | 
            +
             | 
| 1384 | 
            +
                if (valueLength >= MAX_OBJECT_PROPERTY_SIZE) {
         | 
| 1385 | 
            +
                    return ERR_EVENT_MAX_OBJECT_PROPERTY_SIZE;
         | 
| 1386 | 
            +
                }
         | 
| 1387 | 
            +
             | 
| 1388 | 
            +
                if (valueOffset >= (MAX_OBJECT_SIZE - MAX_OBJECT_PROPERTY_SIZE)) {
         | 
| 1389 | 
            +
                    return ERR_EVENT_MAX_OBJECT_SIZE;
         | 
| 1390 | 
            +
                }
         | 
| 1391 | 
            +
             | 
| 1383 1392 | 
             
                jsonProperty *property = &jo->properties[jo->propertiesLength]; 
         | 
| 1384 1393 | 
             
                ++jo->propertiesLength;
         | 
| 1385 1394 | 
             
                if (jo->propertiesLength == MAX_OBJECT_PROPERTIES) {
         | 
    
        data/src/rules/state.h
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 |  | 
| 2 | 
            -
            #include <time.h> | 
| 2 | 
            +
            #include <time.h>
         | 
| 3 3 |  | 
| 4 4 | 
             
            #define HASH_ID 926444256
         | 
| 5 5 | 
             
            #define HASH_SID 3593476751
         | 
| @@ -18,6 +18,8 @@ | |
| 18 18 |  | 
| 19 19 | 
             
            #define UNDEFINED_HASH_OFFSET 0
         | 
| 20 20 | 
             
            #define MAX_OBJECT_PROPERTIES 255
         | 
| 21 | 
            +
            #define MAX_OBJECT_SIZE 4294967296
         | 
| 22 | 
            +
            #define MAX_OBJECT_PROPERTY_SIZE 16777216
         | 
| 21 23 | 
             
            #define MAX_MESSAGE_FRAMES 16
         | 
| 22 24 | 
             
            #define MAX_MESSAGE_INDEX_LENGTH 512
         | 
| 23 25 | 
             
            #define MAX_LEFT_FRAME_INDEX_LENGTH 512
         | 
| @@ -64,8 +66,8 @@ typedef struct pool { | |
| 64 66 | 
             
            typedef struct jsonProperty {
         | 
| 65 67 | 
             
                unsigned int hash;
         | 
| 66 68 | 
             
                unsigned char type;
         | 
| 67 | 
            -
                unsigned  | 
| 68 | 
            -
                unsigned  | 
| 69 | 
            +
                unsigned int valueOffset;
         | 
| 70 | 
            +
                unsigned int valueLength;
         | 
| 69 71 | 
             
                union {
         | 
| 70 72 | 
             
                    long long i; 
         | 
| 71 73 | 
             
                    double d; 
         | 
| @@ -193,8 +195,8 @@ unsigned int getObjectProperty(jsonObject *jo, | |
| 193 195 | 
             
            unsigned int setObjectProperty(jsonObject *jo, 
         | 
| 194 196 | 
             
                                           unsigned int hash, 
         | 
| 195 197 | 
             
                                           unsigned char type, 
         | 
| 196 | 
            -
                                           unsigned  | 
| 197 | 
            -
                                           unsigned  | 
| 198 | 
            +
                                           unsigned int valueOffset, 
         | 
| 199 | 
            +
                                           unsigned int valueLength);
         | 
| 198 200 |  | 
| 199 201 | 
             
            unsigned int constructObject(char *root,
         | 
| 200 202 | 
             
                                         char *parentName, 
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: durable_rules
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0. | 
| 4 | 
            +
              version: 2.0.27
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jesus Ruiz
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-06-07 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         |