remove signatur checking (we do not use included git anymore) (#5018)

This commit is contained in:
Matthias Mair 2023-06-12 12:10:13 +02:00 committed by GitHub
parent 9f56ee1023
commit 2f98ed7022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3 additions and 64 deletions

View File

@ -1616,13 +1616,6 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'requires_restart': True,
},
'PLUGIN_CHECK_SIGNATURES': {
'name': _('Check plugin signatures'),
'description': _('Check and show signatures for plugins'),
'default': False,
'validator': bool,
},
# Settings for plugin mixin features
'ENABLE_PLUGINS_URL': {
'name': _('Enable URL integration'),

View File

@ -128,42 +128,14 @@ def get_git_log(path):
commit.author.decode().split('<')[1][:-1],
datetime.datetime.fromtimestamp(commit.author_time, ).isoformat(),
commit.message.decode().split('\n')[0],
'E',
None
]
except NotGitRepository:
pass
if not output:
output = 7 * [''] # pragma: no cover
output = 5 * [''] # pragma: no cover
return {'hash': output[0], 'author': output[1], 'mail': output[2], 'date': output[3], 'message': output[4], 'verified': output[5], 'key': output[6]}
class GitStatus:
"""Class for resolving git gpg singing state."""
class Definition:
"""Definition of a git gpg sing state."""
key: str = 'N'
status: int = 2
msg: str = ''
def __init__(self, key: str = 'N', status: int = 2, msg: str = '') -> None:
"""Define a git Status -> needed for lookup."""
self.key = key
self.status = status
self.msg = msg
N = Definition(key='N', status=2, msg='no signature',)
G = Definition(key='G', status=0, msg='valid signature',)
B = Definition(key='B', status=2, msg='bad signature',)
U = Definition(key='U', status=1, msg='good signature, unknown validity',)
X = Definition(key='X', status=1, msg='good signature, expired',)
Y = Definition(key='Y', status=1, msg='good signature, expired key',)
R = Definition(key='R', status=2, msg='good signature, revoked key',)
E = Definition(key='E', status=1, msg='cannot be checked',)
return {'hash': output[0], 'author': output[1], 'mail': output[2], 'date': output[3], 'message': output[4]}
# endregion

View File

@ -14,7 +14,7 @@ from django.urls.base import reverse
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from plugin.helpers import GitStatus, get_git_log
from plugin.helpers import get_git_log
logger = logging.getLogger("inventree")
@ -394,16 +394,6 @@ class InvenTreePlugin(VersionMixin, MixinBase, MetaBase):
if package.get('date'):
package['date'] = datetime.fromisoformat(package.get('date'))
# process sign state
sign_state = getattr(GitStatus, str(package.get('verified')), GitStatus.N)
if sign_state.status == 0:
self.sign_color = 'success' # pragma: no cover
elif sign_state.status == 1:
self.sign_color = 'warning'
else:
self.sign_color = 'danger' # pragma: no cover
# set variables
self.package = package
self.sign_state = sign_state
# endregion

View File

@ -24,8 +24,6 @@
{% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_NAVIGATION" icon="fa-sitemap" %}
{% include "InvenTree/settings/setting.html" with key="ENABLE_PLUGINS_APP" icon="fa-rocket" %}
{% include "InvenTree/settings/setting.html" with key="PLUGIN_ON_STARTUP" %}
<tr><td colspan='5'></td></tr>
{% include "InvenTree/settings/setting.html" with key="PLUGIN_CHECK_SIGNATURES" %}
</tbody>
</table>
</div>

View File

@ -118,20 +118,6 @@
<td>{% trans "Commit Message" %}</td><td>{{ plugin.package.message }}{% include "clip.html" %}</td>
</tr>
{% endif %}
{% settings_value "PLUGIN_CHECK_SIGNATURES" as signatures %}
{% if signatures %}
<tr>
<td><span class='text-{{ plugin.sign_color }} fas fa-check'></span></td>
<td>{% trans "Sign Status" %}</td>
<td class="bg-{{ plugin.sign_color }}">{% if plugin.package.verified %}{{ plugin.package.verified }}: {% endif %}{{ plugin.sign_state.msg }}</td>
</tr>
<tr>
<td><span class='text-{{ plugin.sign_color }} fas fa-key'></span></td>
<td>{% trans "Sign Key" %}</td>
<td class="bg-{{ plugin.sign_color }}">{{ plugin.package.key }}{% include "clip.html" %}</td>
</tr>
{% endif %}
</table>
</div>
</div>