Attention is currently required from: iedemam, neels, fixeria, daniel, lynxis lazus.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27137 )
Change subject: stats: sanitize tcp stat name identifiers
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
> Perhaps my comment is misleading. […]
Oh then I'd expect osmo_stat_item_group_set_name to already do some sanitizing, maybe that's not correct in current implementation? Did you check osmo_stat_item_group_set_name implementation? I added Daniel as reviewer, he may know better.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27137
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib04c2f5bfcbd6c19dd87debf1fc053abf0b9bef2
Gerrit-Change-Number: 27137
Gerrit-PatchSet: 1
Gerrit-Owner: iedemam <michael(a)kapsulate.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: iedemam <michael(a)kapsulate.com>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Comment-Date: Thu, 10 Feb 2022 22:15:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: iedemam <michael(a)kapsulate.com>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: pespin.
iedemam has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27137 )
Change subject: stats: sanitize tcp stat name identifiers
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
> I'd argue it's not the duty of stats to be "friendly as filenames", but rather something specific to […]
Perhaps my comment is misleading. Yes, I'm converting these into file names based on the statsd key name. But what we're using right now in tcp_stats for names are not valid for statsd. They need to be sanitized like the GPRS NS2 names are before being used as statsd key names.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27137
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib04c2f5bfcbd6c19dd87debf1fc053abf0b9bef2
Gerrit-Change-Number: 27137
Gerrit-PatchSet: 1
Gerrit-Owner: iedemam <michael(a)kapsulate.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 10 Feb 2022 19:18:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/27142 )
Change subject: utils: Fix missing Optional[] in type annotations
......................................................................
utils: Fix missing Optional[] in type annotations
Thanks to Vadim for pointing this out
Change-Id: I6e7d3725f28410d66580e88f2271d2b240d1f98e
---
M pySim/utils.py
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/42/27142/1
diff --git a/pySim/utils.py b/pySim/utils.py
index 3ce3e58..555aa82 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1253,7 +1253,7 @@
has the habit of specifying TLV data but with very spcific ordering, or specific choices of
tags at specific points in a stream. This class tries to represent this."""
- def __init__(self, name: str, desc: str = None, tag: int = None):
+ def __init__(self, name: str, desc: Optional[str] = None, tag: Optional[int] = None):
"""
Args:
name: A brief, all-lowercase, underscore separated string identifier
@@ -1376,7 +1376,7 @@
A given encoded DO may contain any of them in any order, and may contain multiple instances
of each DO."""
- def __init__(self, name: str, desc: str = None, members=None):
+ def __init__(self, name: str, desc: Optional[str] = None, members=None):
self.name = name
self.desc = desc
self.members = members or []
@@ -1491,7 +1491,7 @@
By wrapping them into this formal DataObjectSequence, we can offer convenience methods
for encoding or decoding an entire sequence."""
- def __init__(self, name: str, desc: str = None, sequence=None):
+ def __init__(self, name: str, desc: Optional[str] = None, sequence=None):
self.sequence = sequence or []
self.name = name
self.desc = desc
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27142
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6e7d3725f28410d66580e88f2271d2b240d1f98e
Gerrit-Change-Number: 27142
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/27141 )
Change subject: cosmetic: Switch to consistent four-spaces indent; run autopep8
......................................................................
cosmetic: Switch to consistent four-spaces indent; run autopep8
We had a mixture of tab and 4space based indenting, which is a bad
idea. 4space is the standard in python, so convert all our code to
that. The result unfortuantely still shoed even more inconsistencies,
so I've decided to run autopep8 on the entire code base.
Change-Id: I4a4b1b444a2f43fab05fc5d2c8a7dd6ddecb5f07
---
M pySim-prog.py
M pySim-read.py
M pySim-shell.py
M pySim/__init__.py
M pySim/ara_m.py
M pySim/card_handler.py
M pySim/card_key_provider.py
M pySim/cards.py
M pySim/cat.py
M pySim/commands.py
M pySim/construct.py
M pySim/exceptions.py
M pySim/filesystem.py
M pySim/gsm_r.py
M pySim/iso7816_4.py
M pySim/jsonpath.py
M pySim/profile.py
M pySim/sysmocom_sja2.py
M pySim/tlv.py
M pySim/transport/__init__.py
M pySim/transport/calypso.py
M pySim/transport/modem_atcmd.py
M pySim/transport/pcsc.py
M pySim/transport/serial.py
M pySim/ts_102_221.py
M pySim/ts_31_102.py
M pySim/ts_31_103.py
M pySim/ts_51_011.py
M pySim/utils.py
29 files changed, 7,420 insertions(+), 6,468 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/41/27141/1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27141
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4a4b1b444a2f43fab05fc5d2c8a7dd6ddecb5f07
Gerrit-Change-Number: 27141
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27135 )
Change subject: ts_31_102: TLV._tlv must point to the class, not an instance
......................................................................
ts_31_102: TLV._tlv must point to the class, not an instance
In Change-Id I6d7c1bf49a8eaf3d8e50fb12888bf3d5b46b6c55 we fixed the
filesystem code to assume the self._tlv memper is a reference to a
class, and not an instance (as this is what the majority of the code
did).
However, it seems thre wer two instances where we actually had _tlv
reference an instance. Change that to class so it's the same all over
the code base.
Change-Id: Ie4878ad6a92feafe47e375c4f5f3f198921e1e95
---
M pySim/ts_31_102.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index e2ab925..3ae88d3 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -335,7 +335,7 @@
def __init__(self, fid="4f03", sfid=0x03, name='EF.5GS3GPPNSC', rec_len={57, None},
desc='5GS 3GPP Access NAS Security Context'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
- self._tlv = EF_5GS3GPPNSC.FiveGSNasSecurityContext()
+ self._tlv = EF_5GS3GPPNSC.FiveGSNasSecurityContext
# 3GPP TS 31.102 Section 4.4.11.6
class EF_5GAUTHKEYS(TransparentEF):
@@ -351,7 +351,7 @@
def __init__(self, fid='4f05', sfid=0x05, name='EF.5GAUTHKEYS', size={68, None},
desc='5G authentication keys'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
- self._tlv = EF_5GAUTHKEYS.FiveGAuthKeys()
+ self._tlv = EF_5GAUTHKEYS.FiveGAuthKeys
# 3GPP TS 31.102 Section 4.4.11.8
class ProtSchemeIdList(BER_TLV_IE, tag=0xa0):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27135
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie4878ad6a92feafe47e375c4f5f3f198921e1e95
Gerrit-Change-Number: 27135
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27133 )
Change subject: utils.py: Fix some tuple type annotations
......................................................................
utils.py: Fix some tuple type annotations
Change-Id: I869b0268383f6babd9b51d0ddfce448a1d2dda1e
---
M pySim/utils.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/pySim/utils.py b/pySim/utils.py
index 4eb539b..3e79034 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -161,7 +161,7 @@
# length value coding is equal to BER-TLV
-def comprehensiontlv_parse_one(binary:bytes) -> (dict, int, bytes, bytes):
+def comprehensiontlv_parse_one(binary:bytes) -> Tuple[dict, int, bytes, bytes]:
"""Parse a single TLV IE at the start of the given binary data.
Args:
binary : binary input data of BER-TLV length field
@@ -311,7 +311,7 @@
else:
raise ValueError("Length > 32bits not supported")
-def bertlv_parse_one(binary:bytes) -> (dict, int, bytes, bytes):
+def bertlv_parse_one(binary:bytes) -> Tuple[dict, int, bytes, bytes]:
"""Parse a single TLV IE at the start of the given binary data.
Args:
binary : binary input data of BER-TLV length field
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27133
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I869b0268383f6babd9b51d0ddfce448a1d2dda1e
Gerrit-Change-Number: 27133
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/27132 )
Change subject: utils.py: type annotations for DataObject related methods
......................................................................
utils.py: type annotations for DataObject related methods
Change-Id: I291a429e9fe9f1a3fd95dcba3020b0e982154c97
---
M pySim/utils.py
1 file changed, 31 insertions(+), 29 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/pySim/utils.py b/pySim/utils.py
index 0a9be86..4eb539b 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1170,7 +1170,7 @@
simply has any number of different TLVs that may occur in any order at any point, ISO 7816
has the habit of specifying TLV data but with very spcific ordering, or specific choices of
tags at specific points in a stream. This class tries to represent this."""
- def __init__(self, name, desc = None, tag = None):
+ def __init__(self, name:str, desc:str = None, tag:int = None):
"""
Args:
name: A brief, all-lowercase, underscore separated string identifier
@@ -1186,10 +1186,10 @@
def __str__(self):
return self.name
- def __repr__(self):
+ def __repr__(self) -> str:
return '%s(%s)' % (self.__class__, self.name)
- def __or__(self, other):
+ def __or__(self, other) -> 'DataObjectChoice':
"""OR-ing DataObjects together renders a DataObjectChoice."""
if isinstance(other, DataObject):
# DataObject | DataObject = DataObjectChoice
@@ -1197,17 +1197,19 @@
else:
raise TypeError
- def __add__(self, other):
+ def __add__(self, other) -> 'DataObjectCollection':
"""ADD-ing DataObjects together renders a DataObjectCollection."""
if isinstance(other, DataObject):
# DataObject + DataObject = DataObjectCollectin
return DataObjectCollection(None, members=[self, other])
+ else:
+ raise TypeError
- def _compute_tag(self):
+ def _compute_tag(self) -> int:
"""Compute the tag (sometimes the tag encodes part of the value)."""
return self.tag
- def to_dict(self):
+ def to_dict(self) -> dict:
"""Return a dict in form "name: decoded_value" """
return {self.name: self.decoded}
@@ -1219,13 +1221,13 @@
"""
@abc.abstractmethod
- def to_bytes(self):
+ def to_bytes(self) -> bytes:
"""Encode the internal state of this instance into the TLV value part.
Returns:
binary bytes encoding the internal state
"""
- def from_tlv(self, do:bytes):
+ def from_tlv(self, do:bytes) -> bytes:
"""Parse binary TLV representation into internal state. The resulting decoded
representation is _not_ returned, but just internalized in the object instance!
Args:
@@ -1241,7 +1243,7 @@
# return remaining bytes
return do[2+length:]
- def to_tlv(self):
+ def to_tlv(self) -> bytes:
"""Encode internal representation to binary TLV.
Returns:
bytes encoded in TLV format.
@@ -1250,7 +1252,7 @@
return bytes(self._compute_tag()) + bytes(len(val)) + val
# 'codec' interface
- def decode(self, binary:bytes):
+ def decode(self, binary:bytes) -> Tuple[dict, bytes]:
"""Decode a single DOs from the input data.
Args:
binary : binary bytes of encoded data
@@ -1265,12 +1267,12 @@
return (self.to_dict(), remainder)
# 'codec' interface
- def encode(self):
+ def encode(self) -> bytes:
return self.to_tlv()
class TL0_DataObject(DataObject):
"""Data Object that has Tag, Len=0 and no Value part."""
- def __init__(self, name, desc, tag, val=None):
+ def __init__(self, name:str, desc:str, tag:int, val=None):
super().__init__(name, desc, tag)
self.val = val
@@ -1279,7 +1281,7 @@
raise ValueError
self.decoded = self.val
- def to_bytes(self):
+ def to_bytes(self) -> bytes:
return b''
@@ -1287,7 +1289,7 @@
"""A DataObjectCollection consits of multiple Data Objects identified by their tags.
A given encoded DO may contain any of them in any order, and may contain multiple instances
of each DO."""
- def __init__(self, name, desc = None, members=None):
+ def __init__(self, name:str, desc:str = None, members=None):
self.name = name
self.desc = desc
self.members = members or []
@@ -1296,15 +1298,15 @@
self.members_by_tag = { m.tag:m for m in members }
self.members_by_name = { m.name:m for m in members }
- def __str__(self):
+ def __str__(self) -> str:
member_strs = [str(x) for x in self.members]
return '%s(%s)' % (self.name, ','.join(member_strs))
- def __repr__(self):
+ def __repr__(self) -> str:
member_strs = [repr(x) for x in self.members]
return '%s(%s)' % (self.__class__, ','.join(member_strs))
- def __add__(self, other):
+ def __add__(self, other) -> 'DataObjectCollection':
"""Extending DataCollections with other DataCollections or DataObjects."""
if isinstance(other, DataObjectCollection):
# adding one collection to another
@@ -1317,7 +1319,7 @@
raise TypeError
# 'codec' interface
- def decode(self, binary:bytes):
+ def decode(self, binary:bytes) -> Tuple[List, bytes]:
"""Decode any number of DOs from the collection until the end of the input data,
or uninitialized memory (0xFF) is found.
Args:
@@ -1343,7 +1345,7 @@
return (res, remainder)
# 'codec' interface
- def encode(self, decoded):
+ def encode(self, decoded) -> bytes:
res = bytearray()
for i in decoded:
obj = self.members_by_name(i[0])
@@ -1358,7 +1360,7 @@
"""We overload the add operator here to avoid inheriting it from DataObjecCollection."""
raise TypeError
- def __or__(self, other):
+ def __or__(self, other) -> 'DataObjectChoice':
"""OR-ing a Choice to another choice extends the choice, as does OR-ing a DataObject."""
if isinstance(other, DataObjectChoice):
# adding one collection to another
@@ -1371,7 +1373,7 @@
raise TypeError
# 'codec' interface
- def decode(self, binary:bytes):
+ def decode(self, binary:bytes) -> Tuple[dict, bytes]:
"""Decode a single DOs from the choice based on the tag.
Args:
binary : binary bytes of encoded data
@@ -1389,7 +1391,7 @@
return (obj.to_dict(), remainder)
# 'codec' interface
- def encode(self, decoded):
+ def encode(self, decoded) -> bytes:
obj = self.members_by_name(decoded[0])
return obj.to_tlv()
@@ -1398,20 +1400,20 @@
ordered sequence of DOs or choices of DOs that have to appear as per the specification.
By wrapping them into this formal DataObjectSequence, we can offer convenience methods
for encoding or decoding an entire sequence."""
- def __init__(self, name, desc=None, sequence=None):
+ def __init__(self, name:str, desc:str=None, sequence=None):
self.sequence = sequence or []
self.name = name
self.desc = desc
- def __str__(self):
+ def __str__(self) -> str:
member_strs = [str(x) for x in self.sequence]
return '%s(%s)' % (self.name, ','.join(member_strs))
- def __repr__(self):
+ def __repr__(self) -> str:
member_strs = [repr(x) for x in self.sequence]
return '%s(%s)' % (self.__class__, ','.join(member_strs))
- def __add__(self, other):
+ def __add__(self, other) -> 'DataObjectSequence':
"""Add (append) a DataObject or DataObjectChoice to the sequence."""
if isinstance(other, 'DataObject'):
return DataObjectSequence(self.name, self.desc, self.sequence + [other])
@@ -1421,7 +1423,7 @@
return DataObjectSequence(self.name, self.desc, self.sequence + other.sequence)
# 'codec' interface
- def decode(self, binary:bytes):
+ def decode(self, binary:bytes) -> Tuple[list, bytes]:
"""Decode a sequence by calling the decoder of each element in the sequence.
Args:
binary : binary bytes of encoded data
@@ -1437,7 +1439,7 @@
return (res, remainder)
# 'codec' interface
- def decode_multi(self, do:bytes):
+ def decode_multi(self, do:bytes) -> Tuple[list, bytes]:
"""Decode multiple occurrences of the sequence from the binary input data.
Args:
do : binary input data to be decoded
@@ -1458,7 +1460,7 @@
return (res, remainder)
# 'codec' interface
- def encode(self, decoded):
+ def encode(self, decoded) -> bytes:
"""Encode a sequence by calling the encoder of each element in the sequence."""
encoded = bytearray()
i = 0
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27132
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I291a429e9fe9f1a3fd95dcba3020b0e982154c97
Gerrit-Change-Number: 27132
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged