Skip to content

Commit d18e955

Browse files
author
BruceHaley
authored
Component Governance python security updates (#1936)
* Fix django vulnerability * vulnerability fix: "django==2.2.28" * Update botbuilder requirements to 4.14.2 * Fix black import error * reformat libraries with latest black * Add component detection * Update urllib3 root dependencies * Revert azure-cognitiveservices-language-luis to 0.2.0 from 0.7.0 * Roll back all urllib3 root dependencies * Revert the last two * git reset to 'Add component detection' commit * git reset to 'Update urllib3 root dependencies' commit * Revert azure-cognitiveservices-language-luis to 0.2.0
1 parent 92bd482 commit d18e955

File tree

108 files changed

+619
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+619
-298
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
botbuilder-integration-aiohttp>=4.14.0
2-
botbuilder-dialogs>=4.14.0
3-
botbuilder-ai>=4.14.0
1+
botbuilder-integration-aiohttp>=4.14.2
2+
botbuilder-dialogs>=4.14.2
3+
botbuilder-ai>=4.14.2
44
datatypes-date-time>=1.0.0.a2
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
botbuilder-integration-aiohttp>=4.14.0
1+
botbuilder-integration-aiohttp>=4.14.2
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
botbuilder-integration-aiohttp>=4.14.0
1+
botbuilder-integration-aiohttp>=4.14.2

libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_adapter.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ async def update_activity(self, context: TurnContext, activity: Activity):
103103

104104
message = SlackHelper.activity_to_slack(activity)
105105
results = await self.slack_client.chat_update(
106-
ts=message.ts, channel=message.channel, text=message.text,
106+
ts=message.ts,
107+
channel=message.channel,
108+
text=message.text,
107109
)
108110

109111
if results.status_code / 100 != 2:

libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_client.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ async def post_message(self, message: SlackMessage) -> SlackResponse:
409409
if message.blocks:
410410
request_content["blocks"] = json.dumps(message.blocks)
411411

412-
session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=30),)
412+
session = aiohttp.ClientSession(
413+
timeout=aiohttp.ClientTimeout(total=30),
414+
)
413415

414416
http_verb = "POST"
415417
api_url = POST_EPHEMERAL_MESSAGE_URL if message.ephemeral else POST_MESSAGE_URL

libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_helper.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def activity_to_slack(activity: Activity) -> SlackMessage:
5656
message.blocks = att.content
5757
else:
5858
new_attachment = Attachment(
59-
author_name=att.name, thumb_url=att.thumbnail_url, text="",
59+
author_name=att.name,
60+
thumb_url=att.thumbnail_url,
61+
text="",
6062
)
6163
attachments.append(new_attachment)
6264

libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ async def _recognize_internal(
262262
if turn_context.activity.type != ActivityTypes.message:
263263
return None
264264

265-
utterance: str = turn_context.activity.text if turn_context.activity is not None else None
265+
utterance: str = (
266+
turn_context.activity.text if turn_context.activity is not None else None
267+
)
266268
recognizer_result: RecognizerResult = None
267269

268270
if luis_prediction_options:

libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer_v2.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def __init__(
4444

4545
async def recognizer_internal(self, turn_context: TurnContext):
4646

47-
utterance: str = turn_context.activity.text if turn_context.activity is not None else None
47+
utterance: str = (
48+
turn_context.activity.text if turn_context.activity is not None else None
49+
)
4850
luis_result: LuisResult = self._runtime.prediction.resolve(
4951
self._application.application_id,
5052
utterance,

libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer_v3.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def __init__(
5555
async def recognizer_internal(self, turn_context: TurnContext):
5656
recognizer_result: RecognizerResult = None
5757

58-
utterance: str = turn_context.activity.text if turn_context.activity is not None else None
58+
utterance: str = (
59+
turn_context.activity.text if turn_context.activity is not None else None
60+
)
5961

6062
url = self._build_url()
6163
body = self._build_request(utterance)

libraries/botbuilder-ai/botbuilder/ai/luis/luis_util.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,14 @@ def recognizer_result_as_dict(
303303
) -> Dict[str, object]:
304304
# an internal method that returns a dict for json serialization.
305305

306-
intents: Dict[str, Dict[str, float]] = {
307-
name: LuisUtil.intent_score_as_dict(intent_score)
308-
for name, intent_score in recognizer_result.intents.items()
309-
} if recognizer_result.intents is not None else None
306+
intents: Dict[str, Dict[str, float]] = (
307+
{
308+
name: LuisUtil.intent_score_as_dict(intent_score)
309+
for name, intent_score in recognizer_result.intents.items()
310+
}
311+
if recognizer_result.intents is not None
312+
else None
313+
)
310314

311315
dictionary: Dict[str, object] = {
312316
"text": recognizer_result.text,

libraries/botbuilder-ai/botbuilder/ai/qna/models/feedback_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class FeedbackRecord(Model):
8-
""" Active learning feedback record. """
8+
"""Active learning feedback record."""
99

1010
_attribute_map = {
1111
"user_id": {"key": "userId", "type": "str"},

libraries/botbuilder-ai/botbuilder/ai/qna/models/feedback_records.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class FeedbackRecords(Model):
8-
""" Active learning feedback records. """
8+
"""Active learning feedback records."""
99

1010
_attribute_map = {"records": {"key": "records", "type": "[FeedbackRecord]"}}
1111

libraries/botbuilder-ai/botbuilder/ai/qna/models/generate_answer_request_body.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class GenerateAnswerRequestBody(Model):
8-
""" Question used as the payload body for QnA Maker's Generate Answer API. """
8+
"""Question used as the payload body for QnA Maker's Generate Answer API."""
99

1010
_attribute_map = {
1111
"question": {"key": "question", "type": "str"},

libraries/botbuilder-ai/botbuilder/ai/qna/models/metadata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Metadata(Model):
8-
""" Metadata associated with the answer. """
8+
"""Metadata associated with the answer."""
99

1010
_attribute_map = {
1111
"name": {"key": "name", "type": "str"},

libraries/botbuilder-ai/botbuilder/ai/qna/models/prompt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Prompt(Model):
8-
""" Prompt Object. """
8+
"""Prompt Object."""
99

1010
_attribute_map = {
1111
"display_order": {"key": "displayOrder", "type": "int"},

libraries/botbuilder-ai/botbuilder/ai/qna/models/qnamaker_trace_info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class QnAMakerTraceInfo:
14-
""" Represents all the trace info that we collect from the QnAMaker Middleware. """
14+
"""Represents all the trace info that we collect from the QnAMaker Middleware."""
1515

1616
def __init__(
1717
self,

libraries/botbuilder-ai/botbuilder/ai/qna/models/query_result.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class QueryResult(Model):
8-
""" Represents an individual result from a knowledge base query. """
8+
"""Represents an individual result from a knowledge base query."""
99

1010
_attribute_map = {
1111
"questions": {"key": "questions", "type": "[str]"},

libraries/botbuilder-ai/botbuilder/ai/qna/models/query_results.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class QueryResults(Model):
10-
""" Contains answers for a user query. """
10+
"""Contains answers for a user query."""
1111

1212
_attribute_map = {
1313
"answers": {"key": "answers", "type": "[QueryResult]"},

libraries/botbuilder-ai/botbuilder/ai/qna/models/ranker_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class RankerTypes:
66

7-
""" Default Ranker Behaviour. i.e. Ranking based on Questions and Answer. """
7+
"""Default Ranker Behaviour. i.e. Ranking based on Questions and Answer."""
88

99
DEFAULT = "Default"
1010

libraries/botbuilder-ai/botbuilder/ai/qna/models/train_request_body.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class TrainRequestBody(Model):
8-
""" Class the models the request body that is sent as feedback to the Train API. """
8+
"""Class the models the request body that is sent as feedback to the Train API."""
99

1010
_attribute_map = {
1111
"feedback_records": {"key": "feedbackRecords", "type": "[FeedbackRecord]"}

libraries/botbuilder-ai/botbuilder/ai/qna/qnamaker.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def __init__(
5555
instance_timeout = ClientTimeout(total=opt.timeout / 1000)
5656
self._http_client = http_client or ClientSession(timeout=instance_timeout)
5757

58-
self.telemetry_client: Union[
59-
BotTelemetryClient, NullTelemetryClient
60-
] = telemetry_client or NullTelemetryClient()
58+
self.telemetry_client: Union[BotTelemetryClient, NullTelemetryClient] = (
59+
telemetry_client or NullTelemetryClient()
60+
)
6161

6262
self.log_personal_information = log_personal_information or False
6363

libraries/botbuilder-ai/botbuilder/ai/qna/utils/active_learning_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class ActiveLearningUtils:
16-
""" Active learning helper class """
16+
"""Active learning helper class"""
1717

1818
@staticmethod
1919
def get_low_score_variation(

libraries/botbuilder-ai/botbuilder/ai/qna/utils/http_request_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class HttpRequestUtils:
17-
""" HTTP request utils class.
17+
"""HTTP request utils class.
1818
1919
Parameters:
2020
-----------

libraries/botbuilder-ai/botbuilder/ai/qna/utils/qna_card_builder.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def get_qna_prompts_card(result: QueryResult, card_no_match_text: str) -> Activi
6262
# Add all prompts
6363
button_list = [
6464
CardAction(
65-
value=prompt.display_text, type="imBack", title=prompt.display_text,
65+
value=prompt.display_text,
66+
type="imBack",
67+
title=prompt.display_text,
6668
)
6769
for prompt in result.context.prompts
6870
]

libraries/botbuilder-ai/botbuilder/ai/qna/utils/train_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class TrainUtils:
14-
""" Class for Train API, used in active learning to add suggestions to the knowledge base """
14+
"""Class for Train API, used in active learning to add suggestions to the knowledge base"""
1515

1616
def __init__(self, endpoint: QnAMakerEndpoint, http_client: ClientSession):
1717
"""
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
msrest==0.6.19
1+
msrest==0.6.21
22
botbuilder-schema==4.15.0
33
botbuilder-core==4.15.0
4-
requests==2.23.0
4+
requests==2.27.1
55
aiounittest==1.3.0
6-
azure-cognitiveservices-language-luis==0.2.0
6+
azure-cognitiveservices-language-luis==0.7.0

libraries/botbuilder-ai/tests/luis/luis_recognizer_test.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ async def test_single_intent_simply_entity(self):
126126

127127
async def test_null_utterance(self):
128128
utterance: str = None
129-
response_path: str = "SingleIntent_SimplyEntity.json" # The path is irrelevant in this case
129+
response_path: str = (
130+
"SingleIntent_SimplyEntity.json" # The path is irrelevant in this case
131+
)
130132

131133
_, result = await LuisRecognizerTest._get_recognizer_result(
132134
utterance, response_path

libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/bot_telemetry_processor.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ class BotTelemetryProcessor(TelemetryProcessor):
1212
"""Application Insights Telemetry Processor for Bot"""
1313

1414
def __init__(self, processors: List[TelemetryProcessor] = None):
15-
self._processors: List[TelemetryProcessor] = [
16-
DjangoTelemetryProcessor(),
17-
FlaskTelemetryProcessor(),
18-
] if processors is None else processors
15+
self._processors: List[TelemetryProcessor] = (
16+
[
17+
DjangoTelemetryProcessor(),
18+
FlaskTelemetryProcessor(),
19+
]
20+
if processors is None
21+
else processors
22+
)
1923

2024
def can_process(self) -> bool:
2125
for processor in self._processors:

libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/flask/flask_telemetry_middleware.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def retrieve_flask_body():
13-
""" retrieve_flask_body
13+
"""retrieve_flask_body
1414
Retrieve the POST body text from temporary cache.
1515
The POST body corresponds with the thread id and should resides in
1616
cache just for lifetime of request.

libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/processor/telemetry_processor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_request_body(self) -> str: # pylint: disable=inconsistent-return-statem
3131
raise NotImplementedError()
3232

3333
def __call__(self, data, context) -> bool:
34-
""" Traditional Web user and session ID's don't apply for Bots. This processor
34+
"""Traditional Web user and session ID's don't apply for Bots. This processor
3535
replaces the identifiers to be consistent with Bot Framework's notion of
3636
user and session id's.
3737
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
msrest==0.6.19
1+
msrest==0.6.21
22
botbuilder-core==4.15.0
33
aiounittest==1.3.0

libraries/botbuilder-applicationinsights/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
]
1313
TESTS_REQUIRES = [
1414
"aiounittest==1.3.0",
15-
"django==2.2.24", # For samples
15+
"django==2.2.28", # For samples
1616
"djangorestframework==3.10.3", # For samples
1717
"flask==1.1.1", # For samples
1818
]

libraries/botbuilder-core/botbuilder/core/adapters/test_adapter.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,18 @@ def create_conversation_reference(
311311
channel_id="test",
312312
service_url="https://test.com",
313313
conversation=ConversationAccount(
314-
is_group=False, conversation_type=name, id=name,
314+
is_group=False,
315+
conversation_type=name,
316+
id=name,
317+
),
318+
user=ChannelAccount(
319+
id=user.lower(),
320+
name=user.lower(),
321+
),
322+
bot=ChannelAccount(
323+
id=bot.lower(),
324+
name=bot.lower(),
315325
),
316-
user=ChannelAccount(id=user.lower(), name=user.lower(),),
317-
bot=ChannelAccount(id=bot.lower(), name=bot.lower(),),
318326
)
319327

320328
def add_user_token(
@@ -657,7 +665,9 @@ async def wait_for_activity():
657665
return TestFlow(await test_flow_previous(), self.adapter)
658666

659667
async def assert_no_reply(
660-
self, description=None, timeout=None, # pylint: disable=unused-argument
668+
self,
669+
description=None,
670+
timeout=None, # pylint: disable=unused-argument
661671
) -> "TestFlow":
662672
"""
663673
Generates an assertion if the bot responds when no response is expected.

libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ async def create_conversation(
400400
if resource_response.activity_id
401401
else str(uuid.uuid4()),
402402
conversation=ConversationAccount(
403-
id=resource_response.id, tenant_id=parameters.tenant_id,
403+
id=resource_response.id,
404+
tenant_id=parameters.tenant_id,
404405
),
405406
channel_data=parameters.channel_data,
406407
recipient=parameters.bot,
@@ -512,7 +513,8 @@ async def process_activity_with_identity(
512513
if invoke_response is None:
513514
return InvokeResponse(status=int(HTTPStatus.NOT_IMPLEMENTED))
514515
return InvokeResponse(
515-
status=invoke_response.value.status, body=invoke_response.value.body,
516+
status=invoke_response.value.status,
517+
body=invoke_response.value.body,
516518
)
517519

518520
return None
@@ -1295,7 +1297,9 @@ def key_for_connector_client(service_url: str, app_id: str, scope: str):
12951297
return f"{service_url if service_url else ''}:{app_id if app_id else ''}:{scope if scope else ''}"
12961298

12971299
async def _create_token_api_client(
1298-
self, context: TurnContext, oauth_app_credentials: AppCredentials = None,
1300+
self,
1301+
context: TurnContext,
1302+
oauth_app_credentials: AppCredentials = None,
12991303
) -> TokenApiClient:
13001304
if (
13011305
not self._is_emulating_oauth_cards

0 commit comments

Comments
 (0)