Skip to content

Commit a951988

Browse files
dgarciabmwiedemann
authored andcommitted
Update python-Js2Py to version 0.74 / rev 10 via SR 1184231
https://build.opensuse.org/request/show/1184231 by user dgarcia + dimstar_suse - Add CVE-2024-28397.patch upstream patch. (bsc#1226660, gh#PiotrDabkowski/Js2Py#323) - Run tests - Add patches: * remove-python-six.patch, to remove python-six dependency * python312.patch, to make it compatible with python312
1 parent 94aaf12 commit a951988

7 files changed

Lines changed: 1226 additions & 6 deletions

File tree

packages/p/python-Js2Py/.files

172 Bytes
Binary file not shown.

packages/p/python-Js2Py/.rev

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,18 @@
7373
<comment></comment>
7474
<requestid>1082036</requestid>
7575
</revision>
76+
<revision rev="10" vrev="3">
77+
<srcmd5>b0e5d3664d2af38e2a5836d5d70e7b1f</srcmd5>
78+
<version>0.74</version>
79+
<time>1719825739</time>
80+
<user>dimstar_suse</user>
81+
<comment>- Add CVE-2024-28397.patch upstream patch.
82+
(bsc#1226660, gh#PiotrDabkowski/Js2Py#323)
83+
- Run tests
84+
- Add patches:
85+
* remove-python-six.patch, to remove python-six dependency
86+
* python312.patch, to make it compatible with python312
87+
</comment>
88+
<requestid>1184231</requestid>
89+
</revision>
7690
</revisionlist>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Index: Js2Py-0.74/js2py/constructors/jsobject.py
2+
===================================================================
3+
--- Js2Py-0.74.orig/js2py/constructors/jsobject.py
4+
+++ Js2Py-0.74/js2py/constructors/jsobject.py
5+
@@ -48,7 +48,7 @@ class ObjectMethods:
6+
raise MakeError(
7+
'TypeError',
8+
'Object.getOwnPropertyDescriptor called on non-object')
9+
- return obj.own.keys()
10+
+ return list(obj.own.keys())
11+
12+
def create(obj):
13+
if not (obj.is_object() or obj.is_null()):

packages/p/python-Js2Py/python-Js2Py.changes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
-------------------------------------------------------------------
2+
Mon Jul 1 08:39:07 UTC 2024 - Daniel Garcia <daniel.garcia@suse.com>
3+
4+
- Add CVE-2024-28397.patch upstream patch.
5+
(bsc#1226660, gh#PiotrDabkowski/Js2Py#323)
6+
7+
-------------------------------------------------------------------
8+
Mon Jul 1 08:19:03 UTC 2024 - Daniel Garcia <daniel.garcia@suse.com>
9+
10+
- Run tests
11+
- Add patches:
12+
* remove-python-six.patch, to remove python-six dependency
13+
* python312.patch, to make it compatible with python312
14+
115
-------------------------------------------------------------------
216
Fri Apr 21 12:20:47 UTC 2023 - Dirk Müller <dmueller@suse.com>
317

packages/p/python-Js2Py/python-Js2Py.spec

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# spec file for package python-Js2Py
33
#
4-
# Copyright (c) 2023 SUSE LLC
4+
# Copyright (c) 2024 SUSE LLC
55
#
66
# All modifications and additions to the file contributed by third parties
77
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,7 +16,6 @@
1616
#
1717

1818

19-
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
2019
%{?sle15_python_module_pythons}
2120
Name: python-Js2Py
2221
Version: 0.74
@@ -27,11 +26,17 @@ Group: Development/Languages/Python
2726
URL: https://github.com/PiotrDabkowski/Js2Py
2827
Source: https://files.pythonhosted.org/packages/source/J/Js2Py/Js2Py-%{version}.tar.gz
2928
Source1: https://raw.githubusercontent.com/PiotrDabkowski/Js2Py/master/LICENSE.md
29+
# PATCH-FIX-OPENSUSE remove-python-six.patch
30+
Patch0: remove-python-six.patch
31+
# PATCH-FIX-UPSTREAM python312.patch gh#PiotrDabkowski/Js2Py#327
32+
Patch1: python312.patch
33+
# PATCH-FIX-UPSTREAM CVE-2024-28397.patch gh#PiotrDabkowski/Js2Py#323
34+
Patch2: CVE-2024-28397.patch
35+
BuildRequires: %{python_module pyjsparser}
3036
BuildRequires: %{python_module setuptools}
3137
BuildRequires: fdupes
3238
BuildRequires: python-rpm-macros
3339
Requires: python-pyjsparser
34-
Requires: python-six
3540
Requires: python-tzlocal
3641
BuildArch: noarch
3742
%python_subpackages
@@ -42,7 +47,7 @@ execute virtually any JavaScript code. Js2Py, basically an
4247
implementation of the JavaScript core, is written in pure Python.
4348

4449
%prep
45-
%setup -q -n Js2Py-%{version}
50+
%autosetup -p1 -n Js2Py-%{version}
4651
cp %{SOURCE1} .
4752

4853
%build
@@ -52,11 +57,18 @@ cp %{SOURCE1} .
5257
%python_install
5358
%python_expand %fdupes %{buildroot}%{$python_sitelib}
5459

55-
# no tests in pypi sdist and no tags in github repo (https://github.com/PiotrDabkowski/Js2Py/issues/100)
60+
%check
61+
pushd tests
62+
touch node_failed.txt
63+
%{python_expand #
64+
PYTHONPATH=%{buildroot}%{$python_sitelib} $python run.py
65+
}
66+
popd
5667

5768
%files %{python_files}
5869
%doc README.md
5970
%license LICENSE.md
60-
%{python_sitelib}/*
71+
%{python_sitelib}/js2py
72+
%{python_sitelib}/Js2Py-%{version}*-info
6173

6274
%changelog
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From fd7df4a91fb08060914c7b1d9e94583d18f3371b Mon Sep 17 00:00:00 2001
2+
From: Felix Yan <felixonmars@archlinux.org>
3+
Date: Wed, 17 Apr 2024 16:47:47 +0300
4+
Subject: [PATCH] Fix bytecode for Python 3.12
5+
6+
`LOAD_ATTR` has been changed in Python 3.12 and it seems reusing the
7+
`LOAD_GLOBAL` logic makes the simple tests passing.
8+
9+
I am not sure if this is correct since I'm pretty new to the code, but
10+
maybe it's still helpful.
11+
---
12+
js2py/translators/translating_nodes.py | 2 +-
13+
js2py/utils/injector.py | 4 +++-
14+
2 files changed, 4 insertions(+), 2 deletions(-)
15+
16+
Index: Js2Py-0.74/js2py/translators/translating_nodes.py
17+
===================================================================
18+
--- Js2Py-0.74.orig/js2py/translators/translating_nodes.py
19+
+++ Js2Py-0.74/js2py/translators/translating_nodes.py
20+
@@ -538,7 +538,7 @@ def TryStatement(type, block, handler, h
21+
if handler:
22+
identifier = handler['param']['name']
23+
holder = 'PyJsHolder_%s_%d' % (to_hex(identifier),
24+
- random.randrange(1e8))
25+
+ random.randrange(six.integer_types[-1](1e8)))
26+
identifier = repr(identifier)
27+
result += 'except PyJsException as PyJsTempException:\n'
28+
# fill in except ( catch ) block and remember to recover holder variable to its previous state
29+
Index: Js2Py-0.74/js2py/utils/injector.py
30+
===================================================================
31+
--- Js2Py-0.74.orig/js2py/utils/injector.py
32+
+++ Js2Py-0.74/js2py/utils/injector.py
33+
@@ -13,6 +13,7 @@ chr = lambda x: x
34+
# Opcode constants used for comparison and replacecment
35+
LOAD_FAST = opcode.opmap['LOAD_FAST']
36+
LOAD_GLOBAL = opcode.opmap['LOAD_GLOBAL']
37+
+LOAD_ATTR = opcode.opmap['LOAD_ATTR']
38+
STORE_FAST = opcode.opmap['STORE_FAST']
39+
40+
41+
@@ -88,6 +89,7 @@ def append_arguments(code_obj, new_local
42+
(co_names.index(name), varnames.index(name)) for name in new_locals)
43+
44+
is_new_bytecode = sys.version_info >= (3, 11)
45+
+ is_new_load_attr = sys.version_info >= (3, 12)
46+
# Now we modify the actual bytecode
47+
modified = []
48+
drop_future_cache = False
49+
@@ -106,7 +108,7 @@ def append_arguments(code_obj, new_local
50+
# it's one of the globals that we are replacing. Either way,
51+
# update its arg using the appropriate dict.
52+
drop_future_cache = False
53+
- if inst.opcode == LOAD_GLOBAL:
54+
+ if inst.opcode == LOAD_GLOBAL or (is_new_load_attr and inst.opcode == LOAD_ATTR):
55+
idx = inst.arg
56+
if is_new_bytecode:
57+
idx = idx // 2

0 commit comments

Comments
 (0)