Skip to content

Commit 07bd55b

Browse files
committed
Merge branch 'main' of https://github.com/cyw3/CodeAnalysis
2 parents 97719f4 + eee37d0 commit 07bd55b

62 files changed

Lines changed: 2790 additions & 169 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Custom rule
3+
about: Regarding the demand for customized rules and false positives and negatives.
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the demand**
11+
A clear and concise description of what the rule is.
12+
13+
14+
**规则概述(Rules Overview)**
15+
16+
17+
**规则背景(Rule Background)**
18+
代码的功能逻辑,按步骤书写。(The functional logic of the code is written in steps.)
19+
20+
21+
**目标问题点(Target Problem Points)**
22+
- 可以按照场景来阐述,比如场景1、场景2这样;(It can be explained by scenario, such as scenario 1 and scenario 2;)
23+
- 每个场景中是第几个步骤可能出现问题,想要解决/检测什么,可以怎么修复,可以结合右边的Case解释。(In each scenario, which step may cause a problem, what you want to solve/detect, and how to fix it. You can explain it in conjunction with the case on the right.)
24+
25+
26+
**错误代码示例(Bad Case)**
27+
28+
29+
**正确代码示例(Good Case)**
30+
31+
32+
**TCA官网上测试项目链接(TCA official website test project link)**
33+
tca.tencent.com
34+
35+
36+
**Additional context**
37+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

client/codepuppy.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
from node.app import settings
2121
from node.common.cmdarg import CmdArgParser
2222
from node.toolloader.loadtool import ToolLoader, ToolConfigLoader
23-
from tool.util.pythontool import PythonTool
24-
from util.exceptions import ConfigError
23+
from node.common.printversion import VersionPrinter
2524
from util.gitconfig import GitConfig
2625
from util.logutil import LogPrinter
2726
from util.textutil import StringMgr
@@ -37,26 +36,18 @@ def __init__(self):
3736
self._params = CmdArgParser.parse_args()
3837
# 日志输出设置
3938
self.__setup_logger()
39+
4040
# 打印版本信息
41-
self.__print_client_version()
41+
VersionPrinter.print_client_version()
42+
# 检查python版本
43+
VersionPrinter.check_python_version()
4244

43-
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
44-
LogPrinter.info('running in a PyInstaller bundle')
45-
else: # 源码执行时,检查是否为python3.7版本
46-
if not PythonTool.is_local_python_command_available("python3", python_version="3.7"):
47-
raise ConfigError("python3 command(Python Version 3.7) is not available, please install first.")
4845
# 运行环境默认编码检查
4946
self.__check_encoding()
5047

5148
# 默认git配置
5249
GitConfig.set_default_config()
5350

54-
def __print_client_version(self):
55-
"""打印TCA客户端版本信息"""
56-
LogPrinter.info("=" * 39)
57-
LogPrinter.info(f"*** TCA Client v{settings.VERSION}({settings.EDITION.name} Beta) ***")
58-
LogPrinter.info("=" * 39)
59-
6051
def __setup_logger(self):
6152
"""日志打印配置
6253
@@ -78,7 +69,6 @@ def __setup_logger(self):
7869
handler.setFormatter(formatter)
7970
root_logger = logging.getLogger()
8071
root_logger.addHandler(handler)
81-
LogPrinter.info(f"Tencent Cloud Code Analysis ({settings.EDITION.name} Beta)")
8272

8373
def __check_encoding(self):
8474
"""检查默认编码,如果为空,设置为en_US.UTF-8
@@ -90,7 +80,7 @@ def __check_encoding(self):
9080
code, encoding = locale.getdefaultlocale()
9181
# LogPrinter.debug('locale is %s.%s' % (code, encoding))
9282
except Exception as err:
93-
LogPrinter.error('locale.getdefaultlocale() encounter err: %s' % str(err))
83+
LogPrinter.warning('locale.getdefaultlocale() encounter err: %s' % str(err))
9484
encoding = None
9585

9686
if encoding is None:
@@ -102,7 +92,6 @@ def __check_encoding(self):
10292

10393
def main(self):
10494
args = self._params
105-
LogPrinter.print_logo()
10695

10796
if args.command == 'localscan':
10897
'''执行本地项目扫描'''

client/node/common/printversion.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# -*- encoding: utf-8 -*-
2+
# Copyright (c) 2021-2024 THL A29 Limited
3+
#
4+
# This source code file is made available under MIT License
5+
# See LICENSE for details
6+
# ==============================================================================
7+
8+
"""
9+
打印客户端版本号
10+
"""
11+
12+
import sys
13+
14+
from node.app import settings
15+
from tool.util.pythontool import PythonTool
16+
from util.exceptions import ConfigError
17+
from util.logutil import LogPrinter
18+
from util.pyinstallerlib import PyinstallerUtil
19+
20+
21+
class RunningType(object):
22+
SourceCode = 5
23+
ExeP = 3
24+
ExeN = 4
25+
26+
27+
class VersionPrinter(object):
28+
@staticmethod
29+
def print_client_version():
30+
running_type = VersionPrinter.get_running_type()
31+
star_str = "*" * running_type
32+
equal_sign_cnt = 31 + len(settings.EDITION.name) + running_type * 2
33+
equal_sign_str = "=" * equal_sign_cnt
34+
LogPrinter.info(equal_sign_str)
35+
LogPrinter.info(f"{star_str} TCA Client v{settings.VERSION}({settings.EDITION.name} Beta) {star_str}")
36+
LogPrinter.info(equal_sign_str)
37+
38+
@staticmethod
39+
def get_running_type():
40+
if sys.argv[0].endswith(".py"):
41+
return RunningType.SourceCode
42+
elif PyinstallerUtil.is_running_in_bundle():
43+
return RunningType.ExeP
44+
else:
45+
return RunningType.ExeN
46+
47+
@staticmethod
48+
def check_python_version():
49+
"""如果是源码执行,检查python版本是否符合"""
50+
if RunningType.SourceCode == VersionPrinter.get_running_type():
51+
# 源码执行时,检查是否为python3.7版本
52+
if not PythonTool.is_local_python_command_available("python3", python_version="3.7"):
53+
raise ConfigError("python3 command(Python Version 3.7) is not available, please install it first.")

client/node/localtask/urlclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_user_info_url(self):
2727
"""
2828
获取用户信息页url
2929
"""
30-
return urljoin(self._base_url, "user/profile")
30+
return urljoin(self._base_url, "user/token")
3131

3232
def get_proj_overview_url(self):
3333
"""

client/util/logutil.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,3 @@ def error(msg, *args, **kwargs):
3535
@staticmethod
3636
def exception(msg, *args, **kwargs):
3737
logger.exception(msg, *args, exc_info=True, **kwargs)
38-
39-
@staticmethod
40-
def print_logo():
41-
logger.info("-" * 30)
42-
logger.info(" ####### #### # ")
43-
logger.info(" # # # # ")
44-
logger.info(" # # ### ")
45-
logger.info(" # # # # ")
46-
logger.info(" # # #####")
47-
logger.info(" # # # # #")
48-
logger.info(" # #### ## ##")
49-
logger.info("-" * 30)
50-

client/util/pyinstallerlib.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- encoding: utf-8 -*-
2+
# Copyright (c) 2021-2023 THL A29 Limited
3+
#
4+
# This source code file is made available under MIT License
5+
# See LICENSE for details
6+
# ==============================================================================
7+
8+
"""
9+
pyinstaller相关的共用类库
10+
"""
11+
12+
import sys
13+
import logging
14+
15+
logger = logging.getLogger(__name__)
16+
17+
18+
class PyinstallerUtil(object):
19+
@staticmethod
20+
def is_running_in_bundle():
21+
"""
22+
检查是否在pyinstaller打包的程序中运行
23+
"""
24+
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
25+
return True
26+
else:
27+
return False

doc/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ bl@^5.0.0:
705705
inherits "^2.0.4"
706706
readable-stream "^3.4.0"
707707

708-
braces@^3.0.2, braces@~3.0.2:
708+
braces@^3.0.3, braces@~3.0.2:
709709
version "3.0.3"
710710
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
711711
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
@@ -1154,11 +1154,11 @@ merge2@^1.3.0, merge2@^1.4.1:
11541154
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
11551155

11561156
micromatch@^4.0.4:
1157-
version "4.0.5"
1158-
resolved "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
1159-
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
1157+
version "4.0.8"
1158+
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
1159+
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
11601160
dependencies:
1161-
braces "^3.0.2"
1161+
braces "^3.0.3"
11621162
picomatch "^2.3.1"
11631163

11641164
mimic-fn@^2.1.0:

helm-charts/tca/README.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ Helm will deploy `mariadb` by default. Reference: [bitnami/mariadb](https://gith
206206
| `tca.web.logPath` | TCA Web nginx log path | `/var/log/nginx` |
207207
208208
### TCA Main configuration parameters
209-
| Name | Description | Value |
210-
| -------------------------------------------- | ------------------------------------------------------------------------ | ------------------------- |
211-
| `tca.main.image.repository` | TCA Main image repository | `tencenttca/tca-main` |
212-
| `tca.main.image.tag` | TCA Main image tag | `latest` |
213-
| `tca.main.server.processnum` | TCA Main server process num | `8` |
214-
| `tca.main.worker.num` | TCA Main worker num for async starting analysis and handle periodic task | `2` |
209+
| Name | Description | Value |
210+
| -------------------------------------------- | ------------------------------------------------------------------------ |-----------------------|
211+
| `tca.main.image.repository` | TCA Main image repository | `tencenttca/tca-main` |
212+
| `tca.main.image.tag` | TCA Main image tag | `latest` |
213+
| `tca.main.server.processnum` | TCA Main server process num | `8` |
214+
| `tca.main.worker.num` | TCA Main worker num for async starting analysis and handle periodic task | `2` |
215+
| `tca.main.server.multiprocDir` | TCA Main server storing monitoring indicator data path | `multiproc-tmp` |
215216
216217
#### TCA Main setting configuration
217218
| Name | Description | Value |
@@ -231,12 +232,14 @@ Helm will deploy `mariadb` by default. Reference: [bitnami/mariadb](https://gith
231232
232233
233234
### TCA Analysis Configuration parameters
234-
| Name | Description | Value |
235-
| -------------------------------------------- | ------------------------------------------------------------------------ | ------------------------- |
236-
| `tca.analysis.image.repository` | TCA Analysis image repository | `tencenttca/tca-analysis` |
237-
| `tca.analysis.image.tag` | TCA Analysis image tag | `latest` |
238-
| `tca.analysis.server.processnum` | TCA Analysis server process num | `8` |
239-
| `tca.analysis.worker.num` | TCA Analysis worker num for async saving lint and metric data | `2` |
235+
| Name | Description | Value |
236+
|----------------------------------------------|---------------------------------------------------------------|---------------------------|
237+
| `tca.analysis.image.repository` | TCA Analysis image repository | `tencenttca/tca-analysis` |
238+
| `tca.analysis.image.tag` | TCA Analysis image tag | `latest` |
239+
| `tca.analysis.server.processnum` | TCA Analysis server process num | `8` |
240+
| `tca.analysis.worker.num` | TCA Analysis worker num for async saving lint and metric data | `2` |
241+
| `tca.analysis.server.multiprocDir` | TCA Analysis server storing monitoring indicator data path | `multiproc-tmp` |
242+
240243
241244
#### TCA Analysis setting configuration
242245
| Name | Description | Value |
@@ -254,11 +257,12 @@ Helm will deploy `mariadb` by default. Reference: [bitnami/mariadb](https://gith
254257
255258
256259
### TCA Login Configuration parameters
257-
| Name | Description | Value |
258-
| -------------------------------------------- | ------------------------------------------------------------------------ | ------------------------- |
259-
| `tca.login.image.repository` | TCA Login image repository | `tencenttca/tca-login` |
260-
| `tca.login.image.tag` | TCA Login image tag | `latest` |
261-
| `tca.login.server.processnum` | TCA Login server process num | `8` |
260+
| Name | Description | Value |
261+
|----------------------------------|----------------------------------------------------------|--------------------------|
262+
| `tca.login.image.repository` | TCA Login image repository | `tencenttca/tca-login` |
263+
| `tca.login.image.tag` | TCA Login image tag | `latest` |
264+
| `tca.login.server.processnum` | TCA Login server process num | `8` |
265+
| `tca.login.server.multiprocDir` | TCA Login server storing monitoring indicator data path | `multiproc-tmp` |
262266
263267
264268
#### TCA Login setting configuration
@@ -271,10 +275,11 @@ Helm will deploy `mariadb` by default. Reference: [bitnami/mariadb](https://gith
271275
| `tca.login.settings.customDB.user` | TCA Login custom mysql server user | `""` |
272276
273277
### TCA File Configuration parameters
274-
| Name | Description | Value |
275-
| -------------------------------------------- | ------------------------------------------------------------------------ | ------------------------- |
276-
| `tca.file.image.repository` | TCA file image repository | `tencenttca/tca-file` |
277-
| `tca.file.image.tag` | TCA file image tag | `latest` |
278+
| Name | Description | Value |
279+
|---------------------------------|---------------------------------------------------------|-----------------------|
280+
| `tca.file.image.repository` | TCA file image repository | `tencenttca/tca-file` |
281+
| `tca.file.image.tag` | TCA file image tag | `latest` |
282+
| `tca.file.server.multiprocDir` | TCA file server storing monitoring indicator data path | `multiproc-tmp` |
278283
279284
#### TCA File setting configuration
280285
| Name | Description | Value |

0 commit comments

Comments
 (0)