-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
850 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
__version__ = "2.5.0" | ||
__version__ = "2.5.1" | ||
VERSION = __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
|
||
# For testing | ||
try: | ||
from django.core.exceptions import ValidationError as UIValidationError | ||
from rest_framework.serializers import ValidationError as APIValidationError | ||
except ImportError: | ||
pass | ||
|
||
|
||
def is_json(json_str): | ||
try: | ||
json.loads(json_str) | ||
except ValueError as e: | ||
return False | ||
return True | ||
|
||
|
||
def validate_api(value): | ||
if not is_json(value): | ||
raise APIValidationError("is not JSON") | ||
|
||
|
||
def validate_ui(value): | ||
if not is_json(value): | ||
raise UIValidationError("is not JSON") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import base64 | ||
import binascii | ||
import struct | ||
|
||
# For testing | ||
try: | ||
from django.core.exceptions import ValidationError as UIValidationError | ||
from rest_framework.serializers import ValidationError as APIValidationError | ||
except ImportError: | ||
pass | ||
|
||
ERROR_MESSAGE = "Is not a valid public ssh key" | ||
|
||
def is_public_ssh_key(ssh_key): | ||
array = ssh_key.split() | ||
# Each rsa-ssh key has 3 different strings in it, first one being | ||
# type_of_key second one being keystring third one being username. | ||
if len(array) not in [2, 3]: | ||
return False | ||
type_of_key = array[0] | ||
ssh_key_str = array[1] | ||
|
||
# must have only valid rsa-ssh key characters ie binascii characters | ||
try: | ||
data = base64.decodebytes(bytes(ssh_key_str, 'utf-8')) | ||
except binascii.Error: | ||
return False | ||
a = 4 | ||
# unpack the contents of ssh_key, from ssh_key[:4] , it must be equal to 7 , property of ssh key . | ||
try: | ||
str_len = struct.unpack('>I', data[:a])[0] | ||
except struct.error: | ||
return False | ||
# ssh_key[4:11] must have string which matches with the type_of_key , another ssh key property. | ||
print(str_len) | ||
if data[a:a + str_len].decode(encoding='utf-8') == type_of_key: | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
def validate_api(value): | ||
if not is_public_ssh_key(value): | ||
raise APIValidationError(ERROR_MESSAGE) | ||
|
||
|
||
def validate_ui(value): | ||
if not is_public_ssh_key(value): | ||
raise UIValidationError(ERROR_MESSAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.utils.html import format_html | ||
from django_tables2 import LinkColumn, TemplateColumn | ||
|
||
from Squest.utils.squest_table import SquestTable | ||
from profiles.models import Scope | ||
|
||
|
||
class ApprovalWorkflowPreviewTable(SquestTable): | ||
|
||
name = LinkColumn() | ||
preview = TemplateColumn(template_name='profiles/custom_columns/preview_workflow.html', orderable=False) | ||
|
||
class Meta: | ||
model = Scope | ||
attrs = {"id": "role_table", "class": "table squest-pagination-tables"} | ||
fields = ("name", "preview") | ||
|
||
def render_name(self, value, record): | ||
return format_html(f'<a title={record} href="{record.get_absolute_url()}">{record}</a>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,3 +93,7 @@ input.form-control[disabled] { | |
.popover { | ||
max-width: 100%; | ||
} | ||
|
||
.callout a{ | ||
color: unset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.