Skip to content

Commit

Permalink
merging branches
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-alessandro-berti committed Dec 18, 2021
2 parents e0fbfcd + 67d2d23 commit 7e90b62
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# PM4Py Changelog

## PM4Py 2.2.17.1 (2021.12.18)

### Fixed
* 2eb36ce5
* Bug fix in OCEL importing (timestamp parsing)
* 512c071e
* Resolved security issue in data Petri nets' PNML parsing


## PM4Py 2.2.17 (2021.12.14)

### Added
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = '2.2'
# The full version, including alpha/beta/rc tags
release = '2.2.17'
release = '2.2.17.1'

# -- General configuration ---------------------------------------------------

Expand Down
28 changes: 28 additions & 0 deletions examples/execute_everything.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
import traceback


def activity_position():
from examples import activity_position
print("\n\nactivity_position")
activity_position.execute_script()


def link_analysis_vbfa():
from examples import link_analysis_vbfa
print("\n\nlink_analysis_vbfa")
link_analysis_vbfa.execute_script()


def ocel_streaming():
from examples import ocel_streaming
print("\n\nocel_streaming")
ocel_streaming.execute_script()


def petri_manual_generation():
from examples import petri_manual_generation
print("\n\npetri_manual_generation")
petri_manual_generation.execute_script()


def timestamp_interleavings():
from examples import timestamp_interleavings
print("\n\ntimestamp_interleavings")
Expand Down Expand Up @@ -495,6 +519,10 @@ def execute_script(f):
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))))

if __name__ == "__main__":
execute_script(activity_position)
execute_script(link_analysis_vbfa)
execute_script(ocel_streaming)
execute_script(petri_manual_generation)
execute_script(timestamp_interleavings)
execute_script(object_centric_petri_net_discovery)
execute_script(trans_system_stochastic_view)
Expand Down
2 changes: 1 addition & 1 deletion examples/petri_manual_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def execute_script():

pm4py.view_petri_net(net, im, fm, format="svg")

pm4py.write_pnml(net, im, fm, "receipt_one_variant.pnml")
#pm4py.write_pnml(net, im, fm, "receipt_one_variant.pnml")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pm4py/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with PM4Py. If not, see <https://www.gnu.org/licenses/>.
'''
VERSION = '2.2.17'
VERSION = '2.2.17.1'

__name__ = 'pm4py'
__version__ = VERSION
Expand Down
18 changes: 18 additions & 0 deletions pm4py/objects/bpmn/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ def get_gatewayDirection(self):
def set_gatewayDirection(self, direction : str):
self.__gatewayDirection = direction

def get_gatewayDirection(self):
return self.__gatewayDirection

def set_gatewayDirection(self, direction : str):
self.__gatewayDirection = direction

class ExclusiveGateway(BPMNNode):
def __init__(self, name="", gatewayDirection="Unspecified", in_arcs=None, out_arcs=None):
BPMN.BPMNNode.__init__(self, name, in_arcs, out_arcs)
Expand All @@ -142,6 +148,12 @@ def get_gatewayDirection(self):
def set_gatewayDirection(self, direction : str):
self.__gatewayDirection = direction

def get_gatewayDirection(self):
return self.__gatewayDirection

def set_gatewayDirection(self, direction : str):
self.__gatewayDirection = direction

class InclusiveGateway(BPMNNode):
def __init__(self, name="", gatewayDirection="Unspecified", in_arcs=None, out_arcs=None):
BPMN.BPMNNode.__init__(self, name, in_arcs, out_arcs)
Expand All @@ -153,6 +165,12 @@ def get_gatewayDirection(self):
def set_gatewayDirection(self, direction : str):
self.__gatewayDirection = direction

def get_gatewayDirection(self):
return self.__gatewayDirection

def set_gatewayDirection(self, direction : str):
self.__gatewayDirection = direction

class Flow(object):
def __init__(self, source, target, name=""):
self.__id = uuid.uuid4()
Expand Down
2 changes: 1 addition & 1 deletion pm4py/objects/ocel/importer/jsonocel/variants/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def apply(file_path: str, parameters: Optional[Dict[Any, Any]] = None) -> OCEL:
dct[k] = v
for obj in ev[constants.OCEL_OMAP_KEY]:
relations.append({event_id: ev_id, event_activity: ev[constants.DEFAULT_EVENT_ACTIVITY],
event_timestamp: ev[constants.DEFAULT_EVENT_TIMESTAMP], object_id: obj,
event_timestamp: parser.apply(ev[constants.DEFAULT_EVENT_TIMESTAMP]), object_id: obj,
object_type: types_dict[obj]})
events.append(dct)

Expand Down
31 changes: 28 additions & 3 deletions pm4py/objects/petri_net/data_petri_nets/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import copy
from pm4py.objects.petri_net import properties as petri_properties
from pm4py.objects.petri_net.sem_interface import Semantics
import re


security_pattern = re.compile(r'[.]|\\x[0-9a-fA-F]+')


class DataPetriNetSemantics(Semantics):
Expand Down Expand Up @@ -93,6 +97,23 @@ def enabled_transitions(self, pn, m, **kwargs):
return enabled_transitions(pn, m, e)


def check_guard_safety(guard):
"""
Checks the security of a guard before evaluating that
Parameters
----------------
guard
Guard
Returns
----------------
safety
True if the guard is safe to execute, False otherwise
"""
return not security_pattern.search(guard)


def evaluate_guard(guard, read_variables, data):
"""
Evaluates a data Petri net guard given the current data
Expand All @@ -111,11 +132,15 @@ def evaluate_guard(guard, read_variables, data):
"""
guard = guard.replace("&&", " and ").replace("||", " or ").replace("true", "True").replace("false", "False")
try:
dct = {}
for k in read_variables:
exec(str(k)+"=None")
dct[k] = None
for k, v in data.items():
exec(str(k)+"="+str(v))
return eval(guard)
dct[k] = v
if check_guard_safety(guard):
ret = eval(guard, dct)
return ret
return False
except:
# the guard could not be evaluated (for example, given missing data)
return False
Expand Down

0 comments on commit 7e90b62

Please sign in to comment.