easy_whitelist 1.0.24__tar.gz → 1.0.37__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/.gitignore +3 -0
  2. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/PKG-INFO +29 -5
  3. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/README.md +9 -3
  4. easy_whitelist-1.0.37/SECURITY.md +13 -0
  5. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/__init__.py +2 -2
  6. easy_whitelist-1.0.24/easy_whitelist/easy.py → easy_whitelist-1.0.37/easy_whitelist/__main__.py +29 -11
  7. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/config/arg.py +7 -8
  8. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/ip/ip.py +20 -7
  9. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/ip/url.py +1 -1
  10. easy_whitelist-1.0.37/easy_whitelist/sample/cvm_sample_detail.py +75 -0
  11. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/tcloud/client.py +8 -6
  12. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/tcloud/template.py +17 -15
  13. easy_whitelist-1.0.37/pyproject.toml +58 -0
  14. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/setup.py +6 -5
  15. easy_whitelist-1.0.24/SECURITY.md +0 -21
  16. easy_whitelist-1.0.24/pyproject.toml +0 -20
  17. easy_whitelist-1.0.24/sample/__init__.py +0 -2
  18. easy_whitelist-1.0.24/sample/aa.py +0 -7
  19. easy_whitelist-1.0.24/sample/memo.md +0 -23
  20. easy_whitelist-1.0.24/sample/test.py +0 -30
  21. easy_whitelist-1.0.24/sample/test2.py +0 -14
  22. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/CODE_OF_CONDUCT.md +0 -0
  23. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/LICENSE +0 -0
  24. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/config/__init__.py +0 -0
  25. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/ip/__init__.py +0 -0
  26. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/ip/agent.py +0 -0
  27. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/ip/pattern.py +0 -0
  28. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37/easy_whitelist}/sample/common_client_sample.py +0 -0
  29. /easy_whitelist-1.0.24/sample/sample.py → /easy_whitelist-1.0.37/easy_whitelist/sample/cvm_sample_simple.py +0 -0
  30. {easy_whitelist-1.0.24 → easy_whitelist-1.0.37}/easy_whitelist/tcloud/__init__.py +0 -0
@@ -2,3 +2,6 @@
2
2
  .vscode/
3
3
  *.code-workspace
4
4
  dist/
5
+ build/
6
+ *.egg-info
7
+ tests/
@@ -1,20 +1,38 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easy_whitelist
3
- Version: 1.0.24
4
- Summary: Easy_whitelist is a small tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
3
+ Version: 1.0.37
4
+ Summary: Easy_whitelist is a smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
5
+ Keywords: automation,whitelist,acl,security-groups,alibaba-cloud,tencent-cloud,security-tools,security-group-rule
5
6
  Author: qiqilelebaobao
6
7
  Author-email: qiqilelebaobao <qiqilelebaobao@163.com>
7
8
  Maintainer-email: qiqilelebaobao <qiqilelebaobao@163.com>
9
+ Requires-Python: >= 3.6
8
10
  Description-Content-Type: text/markdown
9
11
  Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.6
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
10
23
  Requires-Dist: tencentcloud-sdk-python
24
+ Requires-Dist: rich ; extra == "cli"
25
+ Requires-Dist: click ; extra == "cli"
26
+ Requires-Dist: PyQt5 ; extra == "gui"
11
27
  Project-URL: Homepage, https://github.com/qiqilelebaobao/easy_whitelist
28
+ Provides-Extra: cli
29
+ Provides-Extra: gui
12
30
 
13
31
  # Easy_whitelist
14
32
 
15
33
  Easy_whitelist 是一个探测本机互联网 IP 地址,将并本机互联网IP地址,自动更新到云安全组白名单的小工具。工具使用 Python 编写。
16
34
 
17
- Easy_whitelist is a small tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
35
+ Easy_whitelist is a smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
18
36
 
19
37
  主要功能包括:
20
38
  * 自动探测本机互联网 IP 地址
@@ -41,9 +59,15 @@ Main functions include:
41
59
  需要 Python3 环境
42
60
  Python3 is required
43
61
 
44
- ## 使用说明 Instructions
62
+ ## 使用说明 Basic Usage
45
63
 
64
+ * 通过列表选择模版,设置白名单
46
65
  ```shell
47
- $ python3 easy.py -t template list
66
+ $ easy template list
67
+ ```
68
+
69
+ * 通过新创建模版,设置白名单。需要指定关联的安全组ID
70
+ ```shell
71
+ $ easy template create rule_id
48
72
  ```
49
73
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Easy_whitelist 是一个探测本机互联网 IP 地址,将并本机互联网IP地址,自动更新到云安全组白名单的小工具。工具使用 Python 编写。
4
4
 
5
- Easy_whitelist is a small tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
5
+ Easy_whitelist is a smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
6
6
 
7
7
  主要功能包括:
8
8
  * 自动探测本机互联网 IP 地址
@@ -29,8 +29,14 @@ Main functions include:
29
29
  需要 Python3 环境
30
30
  Python3 is required
31
31
 
32
- ## 使用说明 Instructions
32
+ ## 使用说明 Basic Usage
33
33
 
34
+ * 通过列表选择模版,设置白名单
34
35
  ```shell
35
- $ python3 easy.py -t template list
36
+ $ easy template list
37
+ ```
38
+
39
+ * 通过新创建模版,设置白名单。需要指定关联的安全组ID
40
+ ```shell
41
+ $ easy template create rule_id
36
42
  ```
@@ -0,0 +1,13 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Use this section to tell people about which versions of your project are
6
+ currently being supported with security updates.
7
+
8
+
9
+ ## Reporting a Vulnerability
10
+
11
+ Please use https://github.com/qiqilelebaobao to report security vulnerabilities.
12
+
13
+ The Security Team will process your report within a week, and respond within a month (although it will depend on the severity of your report).
@@ -1,6 +1,6 @@
1
- r"""Easy_whitelist is a small tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
1
+ r"""Easy_whitelist is a smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
2
2
  """
3
- __version__ = '1.0.24'
3
+ __version__ = '1.0.37'
4
4
  # __author__ = 'qiqileleabaobao <qiqilelebaobao@163.com>'
5
5
 
6
6
  __all__ = []
@@ -6,12 +6,14 @@ import os
6
6
  import pprint
7
7
  import string
8
8
  import sys
9
+ import logging
9
10
 
10
11
  from easy_whitelist.config import arg
11
12
  from easy_whitelist.tcloud import client
12
13
  from easy_whitelist.tcloud.template import list_template, set_template, create_template
13
14
 
14
- def loop_list(common_client):
15
+
16
+ def loop_list(common_client, proxy=None):
15
17
  template_ids = list_template(common_client)
16
18
  last_input = None
17
19
  while True:
@@ -22,32 +24,48 @@ def loop_list(common_client):
22
24
  if input_from_user.isdigit():
23
25
  if template_ids:
24
26
  if (a := int(input_from_user)) > 0 and a <= len(template_ids):
25
- set_template(common_client, template_ids[a - 1])
27
+ set_template(common_client, template_ids[a - 1], proxy)
26
28
  else:
27
- print('Wrong #, please input # from list.')
29
+ logging.info('Wrong index, please input right index from the list.')
28
30
  elif input_from_user == 'l' or input_from_user == 'L':
29
31
  list_template(common_client)
30
32
  elif input_from_user == 'q' or input_from_user == 'Q':
31
33
  break
34
+ elif input_from_user == '':
35
+ continue
32
36
  else:
33
- print('Input error...')
37
+ logging.info('Input error.')
34
38
 
35
- def main():
36
- tencent, alibaba, action, target, target_id, proxy = arg.init_arg()
37
- # print(tencent, alibaba, action, target, target_id, proxy)
39
+ def set_log(verbose=0):
40
+ # FMT = '%(asctime)s %(process)d %(filename)s L%(lineno)s %(levelname)s %(message)s'
41
+ FMT = '%(asctime)s - %(process)d - %(filename)s - L%(lineno)s - %(levelname)s - %(message)s'
38
42
 
43
+ if verbose == 0:
44
+ logging.basicConfig(level=logging.WARN, format=FMT)
45
+ elif verbose == 1:
46
+ logging.basicConfig(level=logging.INFO, format=FMT)
47
+ elif verbose >=2:
48
+ logging.basicConfig(level=logging.DEBUG, format=FMT)
49
+ else:
50
+ print("Wrong position in set_log.")
51
+
52
+ def main():
53
+ tencent, alibaba, action, target, target_id, proxy, verbose = arg.init_arg()
54
+
55
+ set_log(verbose)
56
+
39
57
  common_client = client.get_common_client(proxy)
40
58
 
41
59
  if tencent and target == 'template':
42
60
  if action == 'list':
43
61
  loop_list(common_client)
44
62
  elif action == 'set':
45
- set_template(common_client, target_id)
63
+ set_template(common_client, target_id, proxy)
46
64
  elif action == 'create':
47
- create_template(common_client, target_id)
65
+ create_template(common_client, target_id, proxy)
48
66
  else:
49
- print('Wrong postion, shall not be here.')
67
+ logging.error('Wrong postion, shall not be here.')
50
68
 
51
- if __name__ == '__main__':
52
69
 
70
+ if __name__ == '__main__':
53
71
  main()
@@ -3,20 +3,19 @@ import argparse
3
3
  def init_arg():
4
4
  '''parse parameter from command line.'''
5
5
 
6
- parser = argparse.ArgumentParser(prog='python3 easy.py', description='This is a cloud acl auto whitelist program.', epilog='Enjoy the tool. :) ')
6
+ parser = argparse.ArgumentParser(prog='easy', description='This is a cloud acl auto whitelist tool.', epilog='Enjoy the tool. :) ')
7
7
 
8
- my_group = parser.add_mutually_exclusive_group(required=True)
9
- my_group.add_argument('-t', '-T', '--tencent', action='store_true', help='tencent cloud')
8
+ my_group = parser.add_mutually_exclusive_group(required=False)
9
+ my_group.add_argument('-t', '-T', '--tencent', action='store_true', default=True, help='tencent cloud')
10
10
  my_group.add_argument('-a', '-A', '--alibaba', action='store_true', help='alibaba cloud')
11
11
 
12
- parser.add_argument('-p', '-P', '--proxy', action='store', default=-1, type=int, help ='local HTTP proxy port')
12
+ parser.add_argument('-p', '-P', '--proxy', action='store', default=None, type=int, help ='local HTTP proxy port')
13
+ parser.add_argument('-v', '--verbose', action='count', default=0)
13
14
 
14
- parser.add_argument('target', help='template or rule', choices=['template', 'rule'])
15
+ parser.add_argument('target', help='template or rule_id', choices=['template', 'rule_id'])
15
16
  parser.add_argument('action', help='list', choices=['list', 'set', 'create'])
16
17
  parser.add_argument('target_id', help='template id or rule id', nargs='?')
17
18
 
18
19
  args = parser.parse_args()
19
20
 
20
- # print(args)
21
-
22
- return args.tencent, args.alibaba, args.action, args.target, args.target_id, args.proxy
21
+ return args.tencent, args.alibaba, args.action, args.target, args.target_id, args.proxy, args.verbose
@@ -2,20 +2,33 @@ import requests
2
2
  import sys
3
3
  import random
4
4
  import re
5
+ import time
6
+ import logging
5
7
 
6
8
  from . import url
7
9
 
8
- def get_local_ip_from_url_and_parse(u, patt, ag):
10
+ def get_local_ip_from_url_and_parse(u, patt, ag, proxy=None):
9
11
  # 发送GET请求
10
12
  headers = {'user-agent': ag}
11
- # print(f'user_agent:{ag}')
12
13
  try:
13
- response = requests.get(u, headers=headers, timeout=60)
14
+ logging.info(f'Starting fetch local ip from {u} with proxy {proxy}')
15
+
16
+ if proxy:
17
+ response = requests.get(u, headers=headers, timeout=(3,5),
18
+ proxies={"http": f"http://127.0.0.1:{proxy}",
19
+ "https": f"http://127.0.0.1:{proxy}"
20
+ })
21
+ else:
22
+ response = requests.get(u, headers=headers, timeout=(3, 5))
23
+
14
24
  # 获取响应内容
15
25
  respon = response.text
16
26
  l_ip = url.parse_ip_from_response(respon, patt)
27
+ logging.info(f'Ending fetch local ip from {u} with ip {l_ip}')
28
+
17
29
  return l_ip
18
- except Exception:
30
+ except Exception as e:
31
+ logging.error(e)
19
32
  return None
20
33
 
21
34
  def validate_ip(l_ip):
@@ -32,11 +45,11 @@ def validate_ip(l_ip):
32
45
  else:
33
46
  return False
34
47
 
35
- def get_local_ips():
48
+ def get_local_ips(proxy=None):
36
49
  ip_list = []
37
50
  for i, u in enumerate(url.detect_url, 1):
38
- l_ip = get_local_ip_from_url_and_parse(u[0], u[1], u[2])
39
- if validate_ip(l_ip):
51
+ l_ip = get_local_ip_from_url_and_parse(u[0], u[1], u[2], proxy)
52
+ if l_ip and validate_ip(l_ip):
40
53
  ip_list.append(l_ip)
41
54
  return ip_list
42
55
 
@@ -11,6 +11,6 @@ def parse_ip_from_response(response, patt):
11
11
 
12
12
  detect_url = [
13
13
  ['https://ifconfig.me', IFCONFIG_ME_PATTERN, random.choice(curl_user_agent)],
14
- ['https://cip.cc', CIP_CC_PATTERN, random.choice(curl_user_agent)],
14
+ ['http://cip.cc', CIP_CC_PATTERN, random.choice(chrome_user_agent)],
15
15
  ['https://tool.lu/ip/', TOOL_LU_PATTERN, random.choice(chrome_user_agent)]
16
16
  ]
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import sys
4
+ import logging
5
+
6
+ from tencentcloud.common import credential
7
+ from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
8
+ # 导入对应产品模块的client models。
9
+ from tencentcloud.cvm.v20170312 import cvm_client, models
10
+
11
+ # 导入可选配置类
12
+ from tencentcloud.common.profile.client_profile import ClientProfile
13
+ from tencentcloud.common.profile.http_profile import HttpProfile
14
+ try:
15
+ # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey。
16
+ # 为了保护密钥安全,建议将密钥设置在环境变量中或者配置文件中,请参考本文凭证管理章节。
17
+ # 硬编码密钥到代码中有可能随代码泄露而暴露,有安全隐患,并不推荐。
18
+ # cred = credential.Credential("secretId", "secretKey")
19
+ cred = credential.Credential(
20
+ os.environ.get("TENCENTCLOUD_SECRET_ID"),
21
+ os.environ.get("TENCENTCLOUD_SECRET_KEY"))
22
+ cred = credential.Credential("SecretId", "SecretKey")
23
+
24
+ # 实例化一个http选项,可选的,没有特殊需求可以跳过。
25
+ httpProfile = HttpProfile()
26
+ # 如果需要指定proxy访问接口,可以按照如下方式初始化hp
27
+ # httpProfile = HttpProfile(proxy="http://用户名:密码@代理IP:代理端口")
28
+ httpProfile.protocol = "https" # 在外网互通的网络环境下支持http协议(默认是https协议),建议使用https协议
29
+ httpProfile.keepAlive = True # 状态保持,默认是False
30
+ httpProfile.reqMethod = "GET" # get请求(默认为post请求)
31
+ httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)
32
+ httpProfile.endpoint = "cvm.ap-shanghai.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
33
+
34
+ # 实例化一个client选项,可选的,没有特殊需求可以跳过。
35
+ clientProfile = ClientProfile()
36
+ clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
37
+ clientProfile.language = "en-US" # 指定展示英文(默认为中文)
38
+ clientProfile.httpProfile = httpProfile
39
+
40
+ # 实例化要请求产品(以cvm为例)的client对象,clientProfile是可选的。
41
+ client = cvm_client.CvmClient(cred, "ap-shanghai", clientProfile)
42
+
43
+ # 打印日志按照如下方式,也可以设置log_format,默认为 '%(asctime)s %(process)d %(filename)s L%(lineno)s %(levelname)s %(message)s'
44
+ # client.set_stream_logger(stream=sys.stdout, level=logging.DEBUG)
45
+ # client.set_file_logger(file_path="/log", level=logging.DEBUG) 日志文件滚动输出,最多10个文件,单个文件最大512MB
46
+ # client.set_default_logger() 去除所有log handler,默认不输出
47
+
48
+ # 实例化一个cvm实例信息查询请求对象,每个接口都会对应一个request对象。
49
+ req = models.DescribeInstancesRequest()
50
+
51
+ # 填充请求参数,这里request对象的成员变量即对应接口的入参。
52
+ # 您可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义。
53
+ respFilter = models.Filter() # 创建Filter对象, 以zone的维度来查询cvm实例。
54
+ respFilter.Name = "zone"
55
+ respFilter.Values = ["ap-shanghai-1", "ap-shanghai-2"]
56
+ req.Filters = [respFilter] # Filters 是成员为Filter对象的列表
57
+
58
+ # python sdk支持自定义header如 X-TC-TraceId、X-TC-Canary,可以按照如下方式指定,header必须是字典类型的
59
+ headers = {
60
+ "X-TC-TraceId": "ffe0c072-8a5d-4e17-8887-a8a60252abca"
61
+ }
62
+ req.headers = headers
63
+
64
+ # 通过client对象调用DescribeInstances方法发起请求。注意请求方法名与请求对象是对应的,headers为可选参数。
65
+ # 返回的resp是一个DescribeInstancesResponse类的实例,与请求对象对应。
66
+ resp = client.DescribeInstances(req)
67
+
68
+ # 输出json格式的字符串回包
69
+ print(resp.to_json_string(indent=2))
70
+
71
+ # 也可以取出单个值。
72
+ # 您可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义。
73
+ print(resp.TotalCount)
74
+ except TencentCloudSDKException as err:
75
+ print(err)
@@ -7,17 +7,19 @@ from tencentcloud.common.common_client import CommonClient
7
7
 
8
8
 
9
9
  def get_common_client(proxy):
10
- cred = credential.Credential(
11
- os.environ.get("TENCENTCLOUD_SECRET_ID"),
12
- os.environ.get("TENCENTCLOUD_SECRET_KEY"))
10
+ # cred = credential.Credential(
11
+ # os.environ.get("TENCENTCLOUD_SECRET_ID"),
12
+ # os.environ.get("TENCENTCLOUD_SECRET_KEY"))
13
+
14
+ cred = credential.DefaultCredentialProvider().get_credential()
13
15
 
14
16
  httpProfile = HttpProfile()
15
- httpProfile.endpoint = "vpc.tencentcloudapi.com"
16
- if proxy != -1:
17
- httpProfile.proxy = f'127.0.0.1:{proxy}'
17
+ # httpProfile.endpoint = "vpc.tencentcloudapi.com"
18
+ httpProfile.proxy = f'127.0.0.1:{proxy}' if proxy else None
18
19
 
19
20
  clientProfile = ClientProfile()
20
21
  clientProfile.httpProfile = httpProfile
22
+ # clientProfile.signMethod = 'HmacSHA256'
21
23
 
22
24
  common_client = CommonClient("vpc", "2017-03-12", cred, "ap-nanjing", profile=clientProfile)
23
25
 
@@ -1,6 +1,7 @@
1
1
  import json
2
2
  import random
3
-
3
+ import sys
4
+ import logging
4
5
 
5
6
  from ..ip import ip
6
7
  from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
@@ -15,8 +16,9 @@ def write_template_list_to_temp_file(template_ids):
15
16
 
16
17
  def get_template(common_client):
17
18
  try:
18
- headers = {}
19
- templates = common_client.call_json("DescribeAddressTemplates", headers)
19
+ params = {}
20
+ # templates = common_client.call_json("DescribeAddressTemplates", params, options = {'SkipSign': True})
21
+ templates = common_client.call_json("DescribeAddressTemplates", params, )
20
22
  return templates
21
23
 
22
24
  except TencentCloudSDKException as err:
@@ -39,7 +41,7 @@ def list_template(common_client):
39
41
  # print(template_ids)
40
42
  addreset = ' ~ '.join(template['AddressSet'][:3])
41
43
  if len(template['AddressSet']) > 3:
42
- addreset += f' ~~~{len(template["AddressSet"])-3} more...'
44
+ addreset += f' ~~~ {len(template["AddressSet"])-3} more...'
43
45
  print(f"{str(i):10}"
44
46
  f"{template['AddressTemplateId']:20}"
45
47
  f"{template['CreatedTime']:30}"
@@ -79,8 +81,8 @@ def modify_template_address(common_client, client_ips, target_id):
79
81
  return False
80
82
  except (TencentCloudSDKException, IndexError) as err:
81
83
  # IndexError catch when there is no match target.Example: 'AddressTemplateSet': []
82
- print(f"{err=}, {type(err)=}, {respon=}")
83
- return False
84
+ print(f"{err=}, {type(err)=}")
85
+ sys.exit(1)
84
86
 
85
87
  params = "{{\"AddressTemplateId\":\"{}\",{}}}".format(target_id, client_ips)
86
88
  try:
@@ -93,29 +95,29 @@ def modify_template_address(common_client, client_ips, target_id):
93
95
 
94
96
  return True
95
97
 
96
- def get_local_ip_and_format_addressesextra():
97
- client_ip_list = ip.get_local_ips()
98
+ def get_local_ip_and_format_addressesextra(proxy=None):
99
+ client_ip_list = ip.get_local_ips(proxy)
98
100
  # ip.print_ip_list(client_ip_list)
99
101
  client_ip_list = list(set(client_ip_list))
100
102
  addresses_extra = format_addres_extra_string_from_list(client_ip_list)
101
103
 
102
104
  return addresses_extra
103
105
 
104
- def set_template(common_client, target_id):
106
+ def set_template(common_client, target_id, proxy=None):
105
107
  # with open('/tmp/template_0000.txt', 'r') as temp_file:
106
108
  # data = json.load(temp_file)
107
109
  # print(data)
108
110
  if target_id:
109
111
  if target_id.startswith('ipm-'):
110
- addresses_extra = get_local_ip_and_format_addressesextra()
112
+ addresses_extra = get_local_ip_and_format_addressesextra(proxy)
111
113
  if modify_template_address(common_client, addresses_extra, target_id):
112
- print(f'Successfully set {{{target_id}}} to {{{addresses_extra}}}')
114
+ logging.info(f'Successfully set {{{target_id}}} to {{{addresses_extra}}}')
113
115
  else:
114
- print('Wrong template id.')
116
+ logging.warning('Wrong template id.')
115
117
  else:
116
- print('Set template shall input template id.')
118
+ logging.error('Set template shall input template id.')
117
119
 
118
- def create_template(common_client, rule_id):
120
+ def create_template(common_client, rule_id, proxy=None):
119
121
 
120
122
  if not rule_id:
121
123
  print('Create template shall input security group id.')
@@ -137,7 +139,7 @@ def create_template(common_client, rule_id):
137
139
  print(f"{err=}, {type(err)=}")
138
140
  return False
139
141
 
140
- addresses_extra = get_local_ip_and_format_addressesextra()
142
+ addresses_extra = get_local_ip_and_format_addressesextra(proxy)
141
143
  params = f"{{\"AddressTemplateName\":\"temp-open-{random.randint(1,9999):04d}\",{addresses_extra}}}"
142
144
  try:
143
145
  respon = common_client.call_json("CreateAddressTemplate", json.loads(params))
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["flit_core >= 3.4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "easy_whitelist"
7
+ authors = [
8
+ {name = "qiqilelebaobao"},
9
+ {name = "qiqilelebaobao", email = "qiqilelebaobao@163.com"}
10
+ ]
11
+ requires-python = ">= 3.6"
12
+
13
+ readme = "README.md"
14
+ license = {text = "Apache License 2.0"}
15
+ classifiers = [
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.6",
20
+ "Programming Language :: Python :: 3.7",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14"
28
+ ]
29
+
30
+ dependencies = [
31
+ "tencentcloud-sdk-python",
32
+ ]
33
+ maintainers = [
34
+ {name = "qiqilelebaobao", email = "qiqilelebaobao@163.com"}
35
+ ]
36
+
37
+ keywords = ["automation", "whitelist", "acl",
38
+ "security-groups", "alibaba-cloud", "tencent-cloud",
39
+ "security-tools", "security-group-rule"]
40
+
41
+ # description = 'Easy_whitelist is a smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.'
42
+
43
+ # version = '1.0.33'
44
+
45
+ dynamic = ["version", "description"]
46
+
47
+ [project.urls]
48
+ Homepage = "https://github.com/qiqilelebaobao/easy_whitelist"
49
+
50
+ [project.scripts]
51
+ easy = "easy_whitelist.__main__:main"
52
+
53
+ [project.optional-dependencies]
54
+ gui = ["PyQt5"]
55
+ cli = [
56
+ "rich",
57
+ "click",
58
+ ]
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # import os
2
3
 
3
- import os
4
4
  from setuptools import setup, find_packages
5
5
 
6
- import easy_whitelist
6
+ # import easy_whitelist
7
7
 
8
8
  # ROOT = os.path.dirname(__file__)
9
9
 
@@ -18,12 +18,13 @@ setup(
18
18
  author='qiqilelebaobao',
19
19
  author_email='qiqilelebaobao@163.com',
20
20
  maintainer_email="qiqilelebaobao@163.com",
21
- version=easy_whitelist.__version__,
22
- url='https://baidu.com',
21
+ version='1.0.34',
22
+ # version=easy_whitelist.__version__,
23
+ url='https://github.com/qiqilelebaobao/easy_whitelist',
23
24
  scripts=[],
24
25
  license="Apache License 2.0",
25
26
  platforms='any',
26
- packages=find_packages(exclude=['output', 'sample']),
27
+ packages=find_packages(exclude=[]),
27
28
  classifiers=[
28
29
  'Development Status :: 5 - Production/Stable',
29
30
  'Intended Audience :: Developers',
@@ -1,21 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- Use this section to tell people about which versions of your project are
6
- currently being supported with security updates.
7
-
8
- | Version | Supported |
9
- | ------- | ------------------ |
10
- | 5.1.x | :white_check_mark: |
11
- | 5.0.x | :x: |
12
- | 4.0.x | :white_check_mark: |
13
- | < 4.0 | :x: |
14
-
15
- ## Reporting a Vulnerability
16
-
17
- Use this section to tell people how to report a vulnerability.
18
-
19
- Tell them where to go, how often they can expect to get an update on a
20
- reported vulnerability, what to expect if the vulnerability is accepted or
21
- declined, etc.
@@ -1,20 +0,0 @@
1
- [build-system]
2
- requires = ["flit_core >=3.2,<4"]
3
- build-backend = "flit_core.buildapi"
4
-
5
- [project]
6
- name = "easy_whitelist"
7
- authors = [{name = "qiqilelebaobao"}, {name = "qiqilelebaobao", email = "qiqilelebaobao@163.com"}]
8
- readme = "README.md"
9
- license = {text = "Apache License 1.0"}
10
- classifiers = ["License :: OSI Approved :: Apache Software License"]
11
- dynamic = ["version", "description"]
12
- dependencies = [
13
- "tencentcloud-sdk-python",
14
- ]
15
- maintainers = [
16
- {name = "qiqilelebaobao", email = "qiqilelebaobao@163.com"}
17
- ]
18
-
19
- [project.urls]
20
- Homepage = "https://github.com/qiqilelebaobao/easy_whitelist"
@@ -1,2 +0,0 @@
1
-
2
- __all__ = ["aa", ]
@@ -1,7 +0,0 @@
1
-
2
-
3
- print(f'name:{__name__}, file:{__file__}, package:{(__package__)}')
4
-
5
- aaa = 3
6
- aab = 4
7
- aac = 5
@@ -1,23 +0,0 @@
1
- Here is Hogan’s full memo:
2
- 、、、
3
- At Microsoft, we deliver mission-critical infrastructure that the world depends on to achieve more. With that trust in us comes a great responsibility: to protect our customers, our company, and our world from cyber threats. As Microsoft employees, we all have a role in that responsibility.
4
-
5
- As Satya referenced in his May 3 email and again during his FY25 kick off on July 9, security is our number-one priority, and everyone at Microsoft will have security as a Core Priority. When faced with a tradeoff, the answer is clear and simple: security above all else. Our commitment to security is enduring. New and novel attacks will require us to continue to learn, innovate, and defend. Yet working together, we will make nonlinear improvements, stay alert, and meet the expectations of our customers. They are counting on us, and our future depends on their trust.
6
-
7
- Our new Security Core Priority reinforces our commitment to security and holds us accountable for building secure products and services. It is now available in the Connect tool for most employees, and we are partnering with geo HR teams to expand access to all employees globally. The Security Core Priority is not a check-the-box compliance exercise; it is a way for every employee and manager to commit to—and be accountable for—prioritizing security, and a way for us to codify your contributions and to recognize you for your impact. We all must act with a security-first mindset, speak up, and proactively look for opportunities to ensure security in everything we do.
8
-
9
- The core priority will have two parts:
10
-
11
- Core and common elements that apply to all employees
12
-
13
- An optional section for employees to further specify how they will activate the Security Core Priority based on their role, team, org, etc.
14
-
15
- All employees will set their Security Core Priority as part their first FY25 Connect, with the intent that during regular Connect conversations, you and your manager will discuss your Security Core Priority progress and impact. This process will follow the same approach as our other company-wide core priorities for Diversity & Inclusion and Managers. You can learn more about the Security Core Priority here, including FAQs and Security Core Priority activation examples for three main types of roles: technical, customer and partner-facing, and all other roles.
16
-
17
- As we kick off our 50th year as a company, I know we all feel honored and humbled that we are still here—as a relevant and consequential company—pursuing our mission together. When we empower every person and organization on the planet to achieve more, we take on society’s biggest challenges and empower the world. What a big, bold, and meaningful mission we have, and yet none of us can take this for granted. We are here because our customers trust us, and we must continue to earn their trust every day.
18
-
19
- Thank you for your commitment to our Security Core Priority that will help protect Microsoft, our customers, and our partners.
20
-
21
- Kathleen
22
-
23
- 、、、
@@ -1,30 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import json
3
- import os
4
-
5
- from tencentcloud.common.common_client import CommonClient
6
- from tencentcloud.common import credential
7
- from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
8
- from tencentcloud.common.profile.client_profile import ClientProfile
9
- from tencentcloud.common.profile.http_profile import HttpProfile
10
-
11
- try:
12
- cred = credential.Credential(
13
- os.environ.get("TENCENTCLOUD_SECRET_ID"),
14
- os.environ.get("TENCENTCLOUD_SECRET_KEY"))
15
-
16
- pass
17
-
18
- httpProfile = HttpProfile()
19
- httpProfile.endpoint = "vpc.tencentcloudapi.com"
20
- httpProfile.proxy = '127.0.0.1:8080'
21
- clientProfile = ClientProfile()
22
- clientProfile.httpProfile = httpProfile
23
-
24
- headers = {}
25
- common_client = CommonClient("vpc", "2017-03-12", cred, "ap-nanjing", profile=clientProfile)
26
- templates = common_client.call_json("DescribeAddressTemplates", headers)
27
- print(json.dumps(templates, ensure_ascii=False))
28
-
29
- except TencentCloudSDKException as err:
30
- print(err)
@@ -1,14 +0,0 @@
1
-
2
- def outer():
3
- x = "local"
4
- def inner():
5
- global y
6
- print("inner:", y)
7
- x = "nonlocal"
8
-
9
- inner()
10
- print("outer:", x)
11
-
12
- x = 'global'
13
- outer()
14
- print('glabal:', x)
File without changes