vesta-web 1.1.1__py3-none-any.whl → 1.1.2__py3-none-any.whl

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.
vesta/db/db_service.py CHANGED
@@ -152,7 +152,7 @@ class DB:
152
152
  else:
153
153
  return []
154
154
  except Exception as e:
155
- print(f"[VESTA] An error occurred with the db: {e}")
155
+ print(f"[VESTA] An error occurred with the db in getFilters: {e}")
156
156
  self.conn.rollback()
157
157
 
158
158
  def insertDict(self, table, dict, getId=False):
@@ -194,8 +194,15 @@ class DB:
194
194
  self.conn.commit()
195
195
 
196
196
  def resetTable(self, table):
197
- sql_str = """delete from {} cascade;ALTER SEQUENCE {} RESTART WITH 1""".format(table, table + "_id_seq")
198
- self.cur.execute(sql_str)
197
+ # Use SQL identifiers to prevent SQL injection
198
+ self.cur.execute(
199
+ sql.SQL("DELETE FROM {} CASCADE").format(sql.Identifier(table))
200
+ )
201
+ self.cur.execute(
202
+ sql.SQL("ALTER SEQUENCE {} RESTART WITH 1").format(
203
+ sql.Identifier(table + "_id_seq")
204
+ )
205
+ )
199
206
  self.conn.commit()
200
207
 
201
208
  def edit(self, table, id, element, value, selector='id'):
@@ -8,5 +8,4 @@ test:
8
8
  - python -m venv venv
9
9
  - source venv/bin/activate
10
10
  - pip install -r requirements.txt
11
- - pip install git+https://gitlab.com/Louciole/vesta.git/
12
11
  - vesta test
@@ -0,0 +1 @@
1
+ vesta-web
vesta/http/baseServer.py CHANGED
@@ -116,7 +116,7 @@ class BaseServer:
116
116
  query = re.split(RE_URL, environ['QUERY_STRING'])
117
117
  for i in range(0, len(query)):
118
118
  query[i] = re.split(RE_PARAM, query[i])
119
- args[query[i][0]] = urllib.parse.unquote(query[i][1])
119
+ args[query[i][0]] = urllib.parse.unquote_plus(query[i][1], encoding='utf-8')
120
120
  if content_type[0] == "multipart/form-data":
121
121
  length = int(environ.get('CONTENT_LENGTH'))
122
122
  body = environ['wsgi.input'].read(length)
vesta/http/response.py CHANGED
@@ -7,7 +7,17 @@ class Response:
7
7
  def __init__(self, start_response, code=200, type="html"):
8
8
  self.cookies = {}
9
9
  self.type = type
10
- self.headers = [('Content-Type', 'text/' + type),('Cache-Control', 'no-cache'), ('Server', 'mag v1 Harpie')]
10
+ self.headers = [
11
+ ('Content-Type', 'text/' + type + '; charset=utf-8'),
12
+ ('Cache-Control', 'no-cache'),
13
+ ('Server', 'Vesta v1 Harpie'),
14
+ # Security headers
15
+ ('X-Content-Type-Options', 'nosniff'),
16
+ ('X-Frame-Options', 'DENY'),
17
+ ('X-XSS-Protection', '1; mode=block'),
18
+ ('Referrer-Policy', 'strict-origin-when-cross-origin'),
19
+ ('Permissions-Policy', 'geolocation=(), microphone=(), camera=()')
20
+ ]
11
21
  self.code = code
12
22
  self.start_response = start_response
13
23
  self.content = ""
@@ -16,21 +26,21 @@ class Response:
16
26
  if self.code != 200 and self.code != 302:
17
27
  if self.code in self.ERROR_PAGES.keys():
18
28
  self.type = "html"
19
- self.headers = [('Content-Type', 'text/html')]
29
+ self.headers = [('Content-Type', 'text/html; charset=utf-8')]
20
30
  file = open(self.ERROR_PAGES[self.code])
21
31
  self.content = file.read()
22
32
  file.close()
23
33
  else:
24
34
  self.type = "plain"
25
- self.headers = [('Content-Type', 'text/plain')]
35
+ self.headers = [('Content-Type', 'text/plain; charset=utf-8')]
26
36
  self.start_response(self.CODES.get(self.code, "500 UNEXPECTED"), self.headers)
27
37
 
28
38
  def encode(self):
29
39
  # print("[INFO] encoding response : ", self.content)
30
40
 
31
41
  if self.type == "plain":
32
- return (self.CODES[self.code] + " " + self.content).encode()
33
- return str(self.content).encode()
42
+ return (self.CODES[self.code] + " " + self.content).encode('utf-8')
43
+ return str(self.content).encode('utf-8')
34
44
 
35
45
  def set_cookie(self, name, value, exp=None, samesite=None, secure=False, httponly=False):
36
46
  """Set a response cookie for the client.
@@ -103,15 +103,16 @@ class Mailing:
103
103
  self.sendMail(mail_confirmation)
104
104
 
105
105
  def sendOrgInvite(self, target, company):
106
- try:
107
- self.template_org_invitation
108
- except:
109
- f = open(self.path + "/mailing/mailInvite.html", "r")
110
- self.template_org_invitation = f.read()
111
- f.close()
112
- self.mail_invitation = MIMEMultipart('alternative')
113
- self.mail_invitation['Subject'] = "🔔 Rejoignez " + company + " 🔔"
114
- self.mail_invitation['From'] = self.name + " <" + self.address + ">"
106
+ if not hasattr(self, 'template_org_invitation'):
107
+ try:
108
+ with open(self.path + "/mailing/mailInvite.html", "r") as f:
109
+ self.template_org_invitation = f.read()
110
+ self.mail_invitation = MIMEMultipart('alternative')
111
+ self.mail_invitation['Subject'] = "🔔 Rejoignez " + company + " 🔔"
112
+ self.mail_invitation['From'] = self.name + " <" + self.address + ">"
113
+ except (FileNotFoundError, IOError) as e:
114
+ print(f"[Vesta - mails] Error loading org invitation template: {e}")
115
+ raise
115
116
 
116
117
  self.mail_invitation['Message-ID'] = email.utils.make_msgid(domain='carbonlab.dev')
117
118
  self.mail_invitation['Date'] = email.utils.formatdate()
vesta/scripts/initDB.py CHANGED
@@ -22,20 +22,22 @@ class DBInitializer(Server):
22
22
  sql.SQL("""
23
23
  CREATE SERVER if not exists uniauth
24
24
  FOREIGN DATA WRAPPER postgres_fdw
25
- OPTIONS (host {}, port {}, dbname {});
26
- """).format(
27
- sql.Literal(self.config.get('UNIAUTH', 'DB_HOST')),
28
- sql.Literal(self.config.get('UNIAUTH', 'DB_PORT')),
29
- sql.Literal(self.config.get('UNIAUTH', 'DB_NAME'))
25
+ OPTIONS (host %s, port %s, dbname %s);
26
+ """),
27
+ (
28
+ self.config.get('UNIAUTH', 'DB_HOST'),
29
+ self.config.get('UNIAUTH', 'DB_PORT'),
30
+ self.config.get('UNIAUTH', 'DB_NAME')
30
31
  ))
31
32
 
32
33
  self.db.cur.execute(
33
34
  sql.SQL("""
34
35
  CREATE USER MAPPING if not exists FOR CURRENT_USER SERVER uniauth
35
- OPTIONS (user '%s', password '%s');
36
- """).format(
37
- sql.Literal(self.config.get('DB', 'DB_USER')),
38
- sql.Literal(self.config.get('DB', 'DB_PASSWORD'))
36
+ OPTIONS (user %s, password %s);
37
+ """),
38
+ (
39
+ self.config.get('DB', 'DB_USER'),
40
+ self.config.get('DB', 'DB_PASSWORD')
39
41
  ))
40
42
  self.db.cur.execute(
41
43
  """
vesta/scripts/testsRun.py CHANGED
@@ -20,14 +20,16 @@ def run_file(file_path):
20
20
  # Look for a 'run' function within the module (assuming tests are run from this function)
21
21
  if hasattr(test_module, 'run'):
22
22
  try:
23
+ count = (0,0)
23
24
  result = test_module.run()
24
25
  for res in result:
25
26
  if res[1] == False:
27
+ count = (count[0],count[1]+1)
26
28
  print(Fore.RED +f"FAILED: '{res[0]}' @{readable_path}")
27
- return False
28
29
  else:
30
+ count = (count[0]+1,count[1]+1)
29
31
  print(Fore.GREEN +f"PASSED: '{res[0]}' @{readable_path}")
30
- return True
32
+ return count
31
33
  except Exception as e:
32
34
  print(f"Error running test file '{readable_path}': {e}")
33
35
  else:
@@ -45,10 +47,8 @@ def run_folder(folder):
45
47
  if file.endswith('.py'):
46
48
  file_path = os.path.join(root, file)
47
49
  res = run_file(file_path)
48
- if res == True:
49
- counter = (counter[0]+1,counter[1]+1)
50
- elif res == False:
51
- counter = (counter[0],counter[1]+1)
50
+ if res:
51
+ counter = (counter[0] + res[0], counter[1] + res[1])
52
52
 
53
53
  return counter
54
54
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vesta-web
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: An extensive web framework adding every feature needed for Carbonlab
5
5
  Project-URL: Homepage, https://gitlab.com/Louciole/vesta
6
6
  Project-URL: Issues, https://gitlab.com/Louciole/vesta/-/issues
@@ -1,13 +1,13 @@
1
1
  vesta/__init__.py,sha256=6aOfxktSRs50uhCMF-473xwmK9Z15uFfvoRXZN2cMos,17865
2
2
  vesta/db/UNIAUTH.sql,sha256=Aroke4pBNrvOh2wZlA09--awCs17BdsyymSVEgLtjDQ,1985
3
- vesta/db/db_service.py,sha256=TIovohU6VjAHAudIWk7aBePPqEVqpy7eR_7-MWg7Mgo,9860
3
+ vesta/db/db_service.py,sha256=E2r6LxxycMOBtpUXWbVIge_363QUCOIJg-MK-Z5dzmw,10058
4
4
  vesta/emptyProject/.gitignore,sha256=9ImxEbKZYcw6fZv2coknCwBdmfY7xWkrOgfBWR03VG0,206
5
- vesta/emptyProject/.gitlab-ci.yml,sha256=y-UMgAb0CVntqhCkh_iWXe3mXzdBmTpmlN-J51vrLEo,371
5
+ vesta/emptyProject/.gitlab-ci.yml,sha256=N3XrdO2CWlAoTOzaX6Gh_vaPRyUdr78Sc9OdKTOnFGQ,310
6
6
  vesta/emptyProject/CONTRIBUTING.md,sha256=kSyO3LxwWrt7i8qmH8IDt0x4y4u18r5u5OvbuoYzMlU,1449
7
7
  vesta/emptyProject/LICENSE.md,sha256=a3dZ32blcDksEC_UGru2vhpuD_JmxXWh4-VMhT1InkQ,644
8
8
  vesta/emptyProject/README.md,sha256=fWesqkMlQPxo3FPl4jFL4RBwbCeTPoyLhUwRBQlV-hM,937
9
9
  vesta/emptyProject/install.sh,sha256=0c3pug86_XfA3wF0atXVTAgjLDG35D_TDW0daE12ejs,663
10
- vesta/emptyProject/requirements.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ vesta/emptyProject/requirements.txt,sha256=ow0jU_n0A4ZAtezF_4okmgqEOur6TSDp845UPXzbtZI,9
11
11
  vesta/emptyProject/server_static.ini,sha256=Bzuqbh_6GU_bqGsEVlw3DQSizQYnaRn-pGshRjsKT2k,86
12
12
  vesta/emptyProject/server_static.py,sha256=SHtoQcv4QZxXUDe58gJYHy0Ghitojl4mSKEOugEVvnQ,329
13
13
  vesta/emptyProject/server_static_orm.ini,sha256=uXF3jcl8rVEDPrU-NvYLKdgOF_1pHbDqoXf1FI46C0U,195
@@ -45,18 +45,18 @@ vesta/emptyProject/static/translations/fr.mjs,sha256=ouMluPVTgB4Q5vmb7zGE6YGTH4U
45
45
  vesta/emptyProject/static/translations/translation.mjs,sha256=JxJ2peSlYVQK-bUKpfddPLXm0XZiz2yu6A6iWIqpKyM,1422
46
46
  vesta/emptyProject/static/ws/onMessage.mjs,sha256=ow5nwSEdiBcvm-Y2zOUMhnqLp-5xWgo11kHviaTRlTw,658
47
47
  vesta/emptyProject/tests/example/foo.py,sha256=NS9oIXFBOvIyWK1LHwkJm9amJuSMN4cxJwouBrJlh2I,115
48
- vesta/http/baseServer.py,sha256=e7cq9xUTVCz3h0W7H3AaIxrz0dUTp_fU6wE2TvjrIJA,8289
48
+ vesta/http/baseServer.py,sha256=7jN0y1SpIRWE9ohzT8IlehTbzy3ofqrOPeKA4vKOC1k,8312
49
49
  vesta/http/error.py,sha256=fWdp-oI2ObJD2mHHuxs1yVJvhON5oHYgYFRLAcUMs-I,180
50
50
  vesta/http/redirect.py,sha256=OiDeOmU-X5Mos8a0BQIeOIJqvgWjDEtaYrM4-x4MXl0,177
51
- vesta/http/response.py,sha256=OLcqq7X9lDyNyJ4xoTOK2zPizr6Lg71_QQPDNnfFliU,3325
52
- vesta/mailing/mailing_service.py,sha256=BfJ_z5mcJiECPFzUR49MJmHZc4VX_Zavdd_b-lwmW14,5212
53
- vesta/scripts/initDB.py,sha256=RhiWOs3tMBf6cQ8Ks8NRW-c6Z8pduGMY6OwojbPvbxU,1714
51
+ vesta/http/response.py,sha256=G7cmbrXFNbIbQoqNxNkR06I5VymIwjFSAe3LtVa56Ok,3760
52
+ vesta/mailing/mailing_service.py,sha256=GBO5Hnspm9Pqwd5kGB0iekZaMoIrfQvrhMUf8tVma7g,5386
53
+ vesta/scripts/cli.py,sha256=xfY-dVzPAbJdmgpRJoGGNSlSXDsMyrQPwykAK017YqE,7506
54
+ vesta/scripts/initDB.py,sha256=TKaK4RZM6CycBEsHeGb9Q9PdphkQgaJDnEWhvRnGC9k,1659
54
55
  vesta/scripts/install.py,sha256=GvH_HHx5aU5_54RQ1_2vz4DaLCh42AHfUKy-m0q21vY,2125
55
- vesta/scripts/testsRun.py,sha256=PQkxKyCwM-TGu9KbLSIkz70o5jnGQSf5aFN9Gil3_1U,2459
56
+ vesta/scripts/testsRun.py,sha256=bXJImdexKQUDW8CR8F9VIKTrgkd7QfnvHQPENEV4x38,2463
56
57
  vesta/scripts/utils.py,sha256=MQZ29b4eplF0OR9EimUToOO73CVoV_cTxQeez2F3OoY,3460
57
- vesta/scripts/vesta.py,sha256=xfY-dVzPAbJdmgpRJoGGNSlSXDsMyrQPwykAK017YqE,7506
58
- vesta_web-1.1.1.dist-info/METADATA,sha256=avBj6zSXwT0FDvjBkpk36sMrjF2hLChFn8-TEB_4RC0,1558
59
- vesta_web-1.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
60
- vesta_web-1.1.1.dist-info/entry_points.txt,sha256=_x509HUdPeKL_Fja0OqUuDa8zKGeLndMxIE_IfojlJg,51
61
- vesta_web-1.1.1.dist-info/licenses/LICENSE.md,sha256=zoPFEFUUoSgosmDBK5fGTWGRHHBaSVuuJT2ZQIYXuIk,177
62
- vesta_web-1.1.1.dist-info/RECORD,,
58
+ vesta_web-1.1.2.dist-info/METADATA,sha256=F1vBrwheV7MlW4UmsKMehblxF1Cleqk1LkNObRJvgU8,1558
59
+ vesta_web-1.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
60
+ vesta_web-1.1.2.dist-info/entry_points.txt,sha256=MHMrWJwtkb4FmNz0CTpxZzwQ3LTqndXBh8YBPDfXlW4,49
61
+ vesta_web-1.1.2.dist-info/licenses/LICENSE.md,sha256=zoPFEFUUoSgosmDBK5fGTWGRHHBaSVuuJT2ZQIYXuIk,177
62
+ vesta_web-1.1.2.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ vesta = vesta.scripts.cli:main
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- vesta = vesta.scripts.vesta:main
File without changes