EnAccess / EnAccess/OpenPAYGO-python

[Bug]: `DISABLE_PAYG` and `COUNTER_SYNC` are incorrectly decoded as `SET_TIME` in extended token mode

未关闭
#24 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Python
星标
15
派生
15
PR 合并指标
30 天内没有已合并 PR

描述

### Preflight Checklist

- [x] I have read the [Contributing Guidelines](https://github.com/EnAccess/OpenPAYGO-python/blob/main/CONTRIBUTING.md) for this project, if it exists.
- [x] I agree to follow the [Code of Conduct](https://github.com/EnAccess/OpenPAYGO-python/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [x] I have searched the [issue tracker](https://github.com/EnAccess/OpenPAYGO-python/issues) for a feature request that matches the one I want to file, without success.

### Expected Behavior

When using OpenPAYGO in Extended Token mode I would expect `DISABLE_PAYG` and `COUNTER_SYNC` to be decoded as such.

### Actual Behavior

However, they are decoded as `SET_TIME` Tokens.

### Steps to reproduce

```python
# OpenPAYGO-python
from openpaygo import OpenPAYGOTokenEncoder, TokenType

encoder = OpenPAYGOTokenEncoder()

new_count, final_token = encoder.generate_token(
secret_key="bc41ec9530f6dac86b1a29ab82edc5fb",
count=4,
value=None,
token_type=TokenType.DISABLE_PAYG,
starting_code=516959010,
restricted_digit_set=False,
extended_token=True,
)

print(f"{new_count=}")
print(f"{final_token=}")
```

```sh
new_count=5
final_token='223770960008'
```

```python
# OpenPAYGO-python
from openpaygo import OpenPAYGOTokenDecoder

decoder = OpenPAYGOTokenDecoder()

value, token_type, count, updated_counts = decoder.decode_token(
secret_key="bc41ec9530f6dac86b1a29ab82edc5fb",
starting_code=516959010,
restricted_digit_set=False,
token="223770960008",
count=4,
)

print(f"{value=}")
print(f"{token_type=}")
print(f"{count=}")
print(f"{updated_counts=}")
```

```sh
value=998.0
token_type=2
count=5
updated_counts=None
```

Note that `token_type=2` is wrong.

### What operating system(s) are you using?

macOS

### Additional Information

_No response_

贡献指南

打开贡献指南

调研方向

首先使用提供的 Python 代码片段,在扩展 token 模式下通过 OpenPAYGOTokenEncoder 和 OpenPAYGOTokenDecoder 重现该问题。将 DISABLE_PAYG 和 COUNTER_SYNC 的解码 token 类型与预期类型进行比较;当两个 token 都被解码为其编码时所使用的类型时即完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
security
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。