Skip to content

Commit c6d09a7

Browse files
committed
Merge branch 'release/2.10.0'
2 parents 2eb3b57 + be862db commit c6d09a7

File tree

20 files changed

+285
-17
lines changed

20 files changed

+285
-17
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Since data is pulled from YWH platform to your server, only regular outbound web
4949

5050
## Changelog
5151

52+
- v2.10:
53+
- added support for new ask for fix process
54+
- added support for report transfer log
5255
- v2.9:
5356
- prevented issue synchronization to fail when tracker file upload is unsuccessful
5457
- v2.8:

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "ywh2bt"
3-
version = "2.9.0"
3+
version = "2.10.0"
44
description = "ywh2bt - YesWeHack to Bug Tracker"
55
readme = "README.md"
66
authors = ["m.honel <m.honel@yeswehack.com>"]
@@ -68,7 +68,7 @@ frozenlist = [
6868
{ version="^1.3.0", python = "<3.8" },
6969
{ version="^1.4.0", python = ">=3.8" },
7070
]
71-
yeswehack = ">=0.8.3"
71+
yeswehack = ">=0.8.7"
7272

7373
[tool.poetry.extras]
7474
gui = ["pyside6"]

stubs/yeswehack/api.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ class Log:
127127
tracker_id: Optional[str]
128128
tracker_token: Optional[str]
129129
fix_verified: bool
130+
old_program: Optional[Dict[str, Any]]
131+
program: Optional[Dict[str, Any]]
132+
old_ask_for_fix_verification_status: Optional[str]
133+
new_ask_for_fix_verification_status: Optional[str]
130134

131135

132136
class Report:
@@ -165,6 +169,7 @@ class Report:
165169
title: Optional[str]
166170
tracking_status: str
167171
vulnerable_part: str
172+
ask_for_fix_verification_status: str
168173

169174
def __init__(
170175
self,
@@ -221,6 +226,13 @@ class Report:
221226
attachments: Optional[List[str]] = None,
222227
) -> List[Log]: ...
223228

229+
def put_ask_for_fix_verification_status(
230+
self,
231+
status: str,
232+
message: Optional[str] = None,
233+
attachments: Optional[List[str]] = None,
234+
) -> List[Log]: ...
235+
224236

225237
class Program:
226238
ywh_api: YesWeHack

ywh2bt/core/api/formatter/formatter.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
from typing_extensions import Protocol
1212

1313
from ywh2bt.core.api.models.report import (
14+
REPORT_ASK_FOR_FIX_VERIFICATION_STATUS_TRANSLATIONS,
1415
REPORT_PROPERTY_LABELS,
1516
REPORT_STATUS_TRANSLATIONS,
17+
AskForFixverificationStatusLog,
1618
CloseLog,
1719
CommentLog,
1820
CvssUpdateLog,
@@ -23,6 +25,7 @@
2325
Report,
2426
RewardLog,
2527
StatusUpdateLog,
28+
TransferLog,
2629
)
2730

2831

@@ -54,6 +57,8 @@ class ReportMessageFormatter(ABC):
5457
_details_update_log_template: Template
5558
_details_update_log_line_template: Template
5659
_priority_update_log_template: Template
60+
_transfer_log_template: Template
61+
_ask_for_fix_verification_status_log_template: Template
5762
_reward_log_template: Template
5863
_value_transformer: _ValueTransformer
5964

@@ -71,6 +76,8 @@ def __init__(
7176
details_update_log_line_template: Template,
7277
priority_update_log_template: Template,
7378
reward_log_template: Template,
79+
transfer_log_template: Template,
80+
ask_for_fix_verification_status_log_template: Template,
7481
value_transformer: Optional[_ValueTransformer] = None,
7582
):
7683
"""
@@ -89,6 +96,8 @@ def __init__(
8996
details_update_log_line_template: a template for entries of a DetailsUpdateLog
9097
priority_update_log_template: a template for a PriorityUpdateLog
9198
reward_log_template: a template for a RewardLog
99+
transfer_log_template: a template for a TransferLog
100+
ask_for_fix_verification_status_log_template: a template for a AskForFixVerificationStatusLog
92101
value_transformer: a transformer for values
93102
"""
94103
self._report_title_template = report_title_template
@@ -104,6 +113,8 @@ def __init__(
104113
self._priority_update_log_template = priority_update_log_template
105114
self._reward_log_template = reward_log_template
106115
self._value_transformer = value_transformer or _identity_transformer
116+
self._transfer_log_template = transfer_log_template
117+
self._ask_for_fix_verification_status_log_template = ask_for_fix_verification_status_log_template
107118

108119
def _transform_value(
109120
self,
@@ -300,6 +311,36 @@ def _transform_fix_verified_log(
300311
),
301312
)
302313

314+
@_transform_log.register
315+
def _transform_transfer_log(
316+
self,
317+
log: TransferLog,
318+
) -> str:
319+
return self._transfer_log_template.substitute(
320+
old_program=(log.old_program or {}).get("title") or "",
321+
program=(log.program or {}).get("title") or "",
322+
comment=self.transform_html(
323+
html=log.message_html,
324+
),
325+
)
326+
327+
@_transform_log.register
328+
def _transform_ask_for_fix_verification_log(
329+
self,
330+
log: AskForFixverificationStatusLog,
331+
) -> str:
332+
return self._ask_for_fix_verification_status_log_template.substitute(
333+
old_ask_for_fix_verification_status=self._translate_ask_for_fix_verification_status(
334+
status=log.old_ask_for_fix_verification_status or "",
335+
),
336+
new_ask_for_fix_verification_status=self._translate_ask_for_fix_verification_status(
337+
status=log.new_ask_for_fix_verification_status or "",
338+
),
339+
comment=self.transform_html(
340+
html=log.message_html,
341+
),
342+
)
343+
303344
@_transform_log.register
304345
def _transform_close_log(
305346
self,
@@ -323,6 +364,12 @@ def _translate_status(
323364
) -> str:
324365
return REPORT_STATUS_TRANSLATIONS.get(status, "")
325366

367+
def _translate_ask_for_fix_verification_status(
368+
self,
369+
status: str,
370+
) -> str:
371+
return REPORT_ASK_FOR_FIX_VERIFICATION_STATUS_TRANSLATIONS.get(status.lower(), "")
372+
326373
@_transform_log.register
327374
def _transform_details_update_log(
328375
self,

ywh2bt/core/api/formatter/markdown.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@
8585
REWARD_LOG_TEMPLATE = """
8686
**Comment from reward**:
8787
88+
${comment}
89+
"""
90+
TRANSFER_LOG_TEMPLATE = """
91+
**Report transferred**:
92+
93+
${old_program} -> ${program}
94+
"""
95+
ASK_FOR_FIX_VERIFICATION_STATUS_LOG_TEMPLATE = """
96+
**Fix verification**:
97+
98+
${new_ask_for_fix_verification_status}
99+
100+
**Comment**:
101+
88102
${comment}
89103
"""
90104

@@ -113,6 +127,8 @@ def __init__(self) -> None:
113127
details_update_log_line_template=Template(DETAILS_UPDATE_LOG_LINE_TEMPLATE),
114128
priority_update_log_template=Template(PRIORITY_UPDATE_LOG_TEMPLATE),
115129
reward_log_template=Template(REWARD_LOG_TEMPLATE),
130+
transfer_log_template=Template(TRANSFER_LOG_TEMPLATE),
131+
ask_for_fix_verification_status_log_template=Template(ASK_FOR_FIX_VERIFICATION_STATUS_LOG_TEMPLATE),
116132
value_transformer=_html_transformer,
117133
)
118134

ywh2bt/core/api/mapping.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from yeswehack.api import Report as YesWeHackRawApiReport
1818

1919
from ywh2bt.core.api.models.report import (
20+
AskForFixverificationStatusLog,
2021
Attachment,
2122
Author,
2223
BugType,
@@ -36,6 +37,7 @@
3637
TrackerMessageLog,
3738
TrackerUpdateLog,
3839
TrackingStatusLog,
40+
TransferLog,
3941
)
4042
from ywh2bt.core.html import (
4143
cleanup_attachments_and_urls_from_html,
@@ -129,6 +131,7 @@ def map_raw_report(
129131
context=context,
130132
raw_program=raw_report.program or {},
131133
),
134+
ask_for_fix_verification_status=raw_report.ask_for_fix_verification_status,
132135
)
133136

134137

@@ -452,6 +455,30 @@ def map_raw_log(
452455
attachments=attachments,
453456
verified=raw_log.fix_verified,
454457
)
458+
if raw_log.type == "transfer":
459+
return TransferLog(
460+
created_at=created_at,
461+
log_id=log_id,
462+
log_type=log_type,
463+
private=private,
464+
author=author,
465+
message_html=message_html,
466+
attachments=attachments,
467+
program=raw_log.program,
468+
old_program=raw_log.old_program,
469+
)
470+
if raw_log.type == "ask-for-fix-verification-status":
471+
return AskForFixverificationStatusLog(
472+
created_at=created_at,
473+
log_id=log_id,
474+
log_type=log_type,
475+
private=private,
476+
author=author,
477+
message_html=message_html,
478+
attachments=attachments,
479+
new_ask_for_fix_verification_status=raw_log.new_ask_for_fix_verification_status,
480+
old_ask_for_fix_verification_status=raw_log.old_ask_for_fix_verification_status,
481+
)
455482
return Log(
456483
created_at=created_at,
457484
log_id=log_id,

ywh2bt/core/api/models/report.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
"auto_close": "Auto Close",
4949
}
5050
)
51+
REPORT_ASK_FOR_FIX_VERIFICATION_STATUS_TRANSLATIONS = MappingProxyType(
52+
{
53+
"pending": "Pending fix verification",
54+
"confirmed": "Fix confirmed",
55+
"rejected": "Fix rejected",
56+
"cancelled": "Fix verification cancelled",
57+
}
58+
)
5159

5260

5361
@dataclass
@@ -73,6 +81,7 @@ class Report:
7381
status: str
7482
tracking_status: str
7583
program: ReportProgram
84+
ask_for_fix_verification_status: str
7685
priority: Optional[Priority] = None
7786

7887
def get_last_tracking_status_update_log(
@@ -330,6 +339,22 @@ class FixVerifiedLog(Log):
330339
verified: bool
331340

332341

342+
@dataclass
343+
class TransferLog(Log):
344+
"""A transfer log."""
345+
346+
old_program: Optional[Dict[str, Any]]
347+
program: Optional[Dict[str, Any]]
348+
349+
350+
@dataclass
351+
class AskForFixverificationStatusLog(Log):
352+
"""A ask-for-fix-verification-status log."""
353+
354+
new_ask_for_fix_verification_status: Optional[str]
355+
old_ask_for_fix_verification_status: Optional[str]
356+
357+
333358
class _LogFilterProtocol(Protocol):
334359
def __call__(
335360
self,

ywh2bt/core/api/trackers/jira/formatter.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@
9090
REWARD_LOG_TEMPLATE = """
9191
*Comment from reward*:
9292
93+
${comment}
94+
"""
95+
TRANSFER_LOG_TEMPLATE = """
96+
*Report transferred*:
97+
98+
${old_program} -> ${program}
99+
"""
100+
ASK_FOR_FIX_VERIFICATION_STATUS_LOG_TEMPLATE = """
101+
*Fix verification*:
102+
103+
${new_ask_for_fix_verification_status}
104+
105+
*Comment*:
106+
93107
${comment}
94108
"""
95109

@@ -152,6 +166,8 @@ def __init__(self) -> None:
152166
details_update_log_line_template=Template(DETAILS_UPDATE_LOG_LINE_TEMPLATE),
153167
priority_update_log_template=Template(PRIORITY_UPDATE_LOG_TEMPLATE),
154168
reward_log_template=Template(REWARD_LOG_TEMPLATE),
169+
transfer_log_template=Template(TRANSFER_LOG_TEMPLATE),
170+
ask_for_fix_verification_status_log_template=Template(ASK_FOR_FIX_VERIFICATION_STATUS_LOG_TEMPLATE),
155171
)
156172

157173
def transform_report_description_html(

ywh2bt/core/api/trackers/servicenow/formatter.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@
8080
Comment from reward:
8181
${comment}
8282
"""
83+
TRANSFER_LOG_TEMPLATE = """
84+
Report transferred:
85+
- ${old_program}
86+
- ${program}
87+
"""
88+
ASK_FOR_FIX_VERIFICATION_STATUS_LOG_TEMPLATE = """
89+
Fix verification:
90+
${new_ask_for_fix_verification_status}
91+
92+
Comment:
93+
${comment}
94+
"""
8395

8496

8597
class ServiceNowReportMessageFormatter(ReportMessageFormatter):
@@ -100,6 +112,8 @@ def __init__(self) -> None:
100112
details_update_log_line_template=Template(DETAILS_UPDATE_LOG_LINE_TEMPLATE),
101113
priority_update_log_template=Template(PRIORITY_UPDATE_LOG_TEMPLATE),
102114
reward_log_template=Template(REWARD_LOG_TEMPLATE),
115+
transfer_log_template=Template(TRANSFER_LOG_TEMPLATE),
116+
ask_for_fix_verification_status_log_template=Template(ASK_FOR_FIX_VERIFICATION_STATUS_LOG_TEMPLATE),
103117
)
104118

105119
def transform_report_description_html(

0 commit comments

Comments
 (0)