Skip to content

Commit 6d2bfc2

Browse files
add remaining jira software paths and string literal handling
1 parent d03af35 commit 6d2bfc2

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

crates/forge_analyzer/src/definitions.rs

+24-19
Original file line numberDiff line numberDiff line change
@@ -1001,18 +1001,28 @@ impl FunctionAnalyzer<'_> {
10011001
fn resolve_jira_api_type(url: &str) -> Option<IntrinsicName> {
10021002
// Pattern matching to classify, eg: api.[asApp | asUser]().requestJira(route`/rest/api/3/myself`);
10031003
match url {
1004+
// JSM requests
10041005
url if url.starts_with("/rest/servicedeskapi/") => {
10051006
Some(IntrinsicName::RequestJiraServiceManagement)
10061007
}
1007-
url if url.starts_with("/rest/agile/") => Some(IntrinsicName::RequestJiraSoftware),
1008-
// Accept Jira API v2.0 or v3.0
1008+
// Jira Software requests from https://developer.atlassian.com/cloud/jira/software/rest/intro/#introduction
1009+
url if url.starts_with("/rest/agile/")
1010+
|| url.starts_with("/rest/devinfo/")
1011+
|| url.starts_with("/rest/featureflags/")
1012+
|| url.starts_with("/rest/deployments/")
1013+
|| url.starts_with("/rest/builds")
1014+
|| url.starts_with("/rest/remotelinks/")
1015+
|| url.starts_with("/rest/security/")
1016+
|| url.starts_with("/rest/operations/")
1017+
|| url.starts_with("/rest/devopscomponents/") =>
1018+
{
1019+
Some(IntrinsicName::RequestJiraSoftware)
1020+
}
1021+
// Jira requests, accept Jira API v2.0 or v3.0
10091022
url if url.starts_with("/rest/api/2/") || url.starts_with("/rest/api/3/") => {
10101023
Some(IntrinsicName::RequestJira)
10111024
}
1012-
_ => {
1013-
warn!("Provided Jira API URL: {:?} is neither Jira, JS, JSM!", url);
1014-
None
1015-
}
1025+
_ => None,
10161026
}
10171027
}
10181028

@@ -1032,21 +1042,16 @@ impl FunctionAnalyzer<'_> {
10321042
// Resolve Jira API requests to either JSM/JS/Jira as all are bundled within requestJira()
10331043
match first_arg {
10341044
Expr::TaggedTpl(TaggedTpl { tpl, .. }) => {
1035-
if let Some(TplElement { raw, .. }) = tpl.quasis.first() {
1036-
resolve_jira_api_type(raw).unwrap_or_else(|| {
1037-
// Conservatively assume any of Jira APIs may be used if we can't statically determine which one
1038-
warn!("Falling back to any Jira request");
1039-
IntrinsicName::RequestJiraAny
1040-
})
1041-
} else {
1042-
panic!("No url identifiable to classify requestJira() type");
1043-
}
1044-
}
1045-
_ => {
1046-
warn!("Unable to classify requestJira() type");
1047-
IntrinsicName::RequestJiraAny
1045+
tpl.quasis.first().map(|elem| &elem.raw)
10481046
}
1047+
Expr::Lit(Lit::Str(str_lit)) => Some(&str_lit.value),
1048+
_ => None,
10491049
}
1050+
.and_then(|atom| resolve_jira_api_type(atom.as_ref()))
1051+
.unwrap_or_else(|| {
1052+
warn!("Could not resolve Jira API type, falling back to any Jira request");
1053+
IntrinsicName::RequestJiraAny
1054+
})
10501055
} else if *last == "requestBitbucket" {
10511056
IntrinsicName::RequestBitbucket
10521057
} else {

0 commit comments

Comments
 (0)