Skip to content

Commit

Permalink
classify jira api requests with url pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
dxu2atlassian committed Jan 2, 2025
1 parent e2fc593 commit 728d723
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions crates/forge_analyzer/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,19 +996,41 @@ impl FunctionAnalyzer<'_> {
[PropPath::Def(def), ref authn @ .., PropPath::Static(ref last)]
if (*last == *"requestJira"
|| *last == *"requestConfluence"
|| *last == *"requestBitbucket") // TODO: resolve Jira API requests to the correct permission map, here JSM (and likely JS) is bundled inside Jira
|| *last == *"requestBitbucket")
&& Some(&ImportKind::Default)
== self.res.is_imported_from(def, "@forge/api") =>
{
let first_arg = first_arg?;
let is_as_app = authn.first() == Some(&PropPath::MemberCall("asApp".into()));

let function_name = if *last == "requestJira" {
IntrinsicName::RequestJira
// Resolve Jira API requests to either JSM/JS/Jira as all are bundled within requestJira
match first_arg {
Expr::Tpl(template) => {
let url = template
.quasis
.iter()
.map(|quasi| quasi.raw.as_str())
.collect::<String>();
match url.as_str() {
url if url.starts_with("/rest/servicedeskapi/") => {
IntrinsicName::RequestJiraServiceManagement
}
url if url.starts_with("/rest/agile/") => {
IntrinsicName::RequestJiraSoftware
}
url if url.starts_with("/rest/api/") => IntrinsicName::RequestJira,
_ => IntrinsicName::RequestJira,
}
}
_ => IntrinsicName::RequestJira,
}
} else if *last == "requestBitbucket" {
IntrinsicName::RequestBitbucket
} else {
IntrinsicName::RequestConfluence
};
let first_arg = first_arg?;
let is_as_app = authn.first() == Some(&PropPath::MemberCall("asApp".into()));

match classify_api_call(first_arg) {
ApiCallKind::Unknown => {
if is_as_app {
Expand Down

0 comments on commit 728d723

Please sign in to comment.