github / github/codeql

(java,bug)SpringRequestMappingMethod::getValue does not return when a constant in jar is used

オープン
#10,989 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

### Version
CodeQL CLI 2.11.2
### Description
as shown below,the method "putDesignToPackage" will not be matched,the reason is that the annotation PostMapping use a constant which is caculate by third party。
### Example

ql:
```
import java
import semmle.code.java.frameworks.spring.SpringController
import custom.lib_1
from SpringController controller, SpringRequestMappingMethod method
where
method = controller.getAMethod()

select method,controller,method.getValue()
```

java code:
```
@PostMapping(value = OpenDesignPackageApis.DESIGN_PACKAGE_PATH_WITH_ID)
public Result putDesignToPackage(
@PathVariable final String obsPackageId,
@RequestParam(value = "plan_id") final String obsPlanId) throws
BizzException {

return Result.ok();
}
```

constant
```
package com.xxx.design.web.api;

import com.aaa.regex.UrlRegex;

public class OpenDesignPackageApis {

public static final String DESIGN_PACKAGE_PATH = OpenDesignApis.DESIGN + "/package";

public static final String DESIGN_PACKAGE_LIST_PATH = DESIGN_PACKAGE_PATH + "/list";

public static final String DESIGN_PACKAGE_PATH_WITH_ID = DESIGN_PACKAGE_PATH +
"/{obsPackageId:" + UrlRegex.OBSCURED_ID_REGEX + "}";
}
```
the source code which maybe has a bug
SpringController.qll
```
class SpringRequestMappingMethod extends SpringControllerMethod {
...
string getValue() {
result = requestMappingAnnotation.getValue("value").(CompileTimeConstantExpr).getStringValue()
}
....
}
```

https://github.com/github/codeql/issues/10989#tasklist-block-21bc8440-4f27-40d4-9ff5-9c2ab8475f10

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。