Skip to content

Commit

Permalink
Merge pull request #224 from hcrudolph/development
Browse files Browse the repository at this point in the history
minor improvements, bug fixes, and dependency updates
  • Loading branch information
hcrudolph committed May 6, 2024
2 parents 9599699 + 47fd5cf commit 01c94b2
Show file tree
Hide file tree
Showing 120 changed files with 217 additions and 11,072 deletions.
37 changes: 4 additions & 33 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
branches: [ "master", "development" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '44 14 * * 3'
branches: [ "master", "development" ]

jobs:
analyze:
Expand All @@ -39,29 +26,13 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
44 changes: 44 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Django CI

on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.11]
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: csinfo
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
DJANGO_SECRET_KEY: "dummy"
DATABASE_URL: "postgres://postgres:postgres@127.0.0.1:5432/csinfo"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements-dev.txt
- name: Run Migrations
run: |
python manage.py migrate
- name: Run Tests
run: |
python manage.py test
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "static/bootstrap"]
path = static/bootstrap
url = https://github.com/hcrudolph/csi-bootstrap-theme.git
2 changes: 1 addition & 1 deletion blog/templates/blog/recent_posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="col-lg-8 col-lg-offset-2">
<h1>Recent Posts</h1>
</div><!-- end column -->
<div class="col-xl-8 col-xl-offset-2">
<div class="col-lg-8 col-lg-offset-2">
<ul class="post-list">
{% for post in posts %}
<li><a href="/blog/{{ post.first_published|date:"Y" }}/{{ post.first_published|date:"m" }}/{{ post.first_published|date:"d" }}/{{ post.slug }}">
Expand Down
2 changes: 1 addition & 1 deletion directory/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MainSearchForm(forms.Form):
max_length=100,
widget=forms.TextInput(
attrs={
'class': 'form-control input-lg',
'class': 'form-control form-control-lg',
'placeholder': 'cipher, algorithm, rfc, vulnerability...',
}
),
Expand Down
68 changes: 15 additions & 53 deletions directory/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def complete_rfc_instance(sender, instance, *args, **kwargs):

def get_year(html):
docinfo = " ".join(
html.xpath('//pre[1]/text()')
)
html.xpath('//tbody[@class="meta align-top border-top"]/tr/td[2]/text()')
).strip()
month_list = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
month_and_year = re.compile(
Expand All @@ -24,43 +24,15 @@ def get_year(html):
match = month_and_year.search(docinfo)
return int(match.group(1))

def get_year_alt(html):
date = " ".join(html.xpath('//time[@class="published"]/text()'))
return int(date.split()[1])

def get_title(html):
headers = html.xpath('//span[@class="h1"]/text()')
return " ".join(headers)

def get_title_alt(html):
return " ".join(html.xpath('//h1[@id="title"]/text()'))
docinfo = " ".join(html.xpath('//h1/text()'))
return docinfo.strip()

def get_status(html):
# concat all fields possibly containing doc status
# get table with document properties
docinfo = " ".join(
html.xpath('//pre[@class="pre meta-info"]/text()')
)

# search for predefined options
if re.search('INTERNET STANDARD', docinfo, re.IGNORECASE):
return 'IST'
elif re.search('PROPOSED STANDARD', docinfo, re.IGNORECASE):
return 'PST'
elif re.search('DRAFT STANDARD', docinfo, re.IGNORECASE):
return 'DST'
elif re.search('BEST CURRENT PRACTISE', docinfo, re.IGNORECASE):
return 'BCP'
elif re.search('INFORMATIONAL', docinfo, re.IGNORECASE):
return 'INF'
elif re.search('EXPERIMENTAL', docinfo, re.IGNORECASE):
return 'EXP'
elif re.search('HISTORIC', docinfo, re.IGNORECASE):
return 'HST'
else:
return 'UND'

def get_status_alt(html):
docinfo = " ".join(html.xpath('//dl[@id="external-updates"]/text()'))
html.xpath('//td/*[contains(text(),"RFC")]/text()')
).strip()

# search for predefined options
if re.search('INTERNET STANDARD', docinfo, re.IGNORECASE):
Expand All @@ -80,24 +52,14 @@ def get_status_alt(html):
else:
return 'UND'

if instance.is_draft:
url = f"https://tools.ietf.org/html/draft-ietf-tls-rfc{instance.number}"
else:
url = f"https://tools.ietf.org/html/rfc{instance.number}"
resp = requests.get(url)
if resp.status_code == 200:
content = html.fromstring(resp.content)
if int(instance.number) < 8650:
instance.url = url
instance.title = get_title(content)
instance.status = get_status(content)
instance.release_year = get_year(content)
# required for parsing new RFC Editor format
elif int(instance.number) > 8650:
instance.url = url
instance.title = get_title_alt(content)
instance.status = get_status_alt(content)
instance.release_year = get_year_alt(content)
url = f"https://datatracker.ietf.org/doc/rfc{instance.number}"
rfc = requests.get(url)
if rfc.status_code == 200:
content = html.fromstring(rfc.content)
instance.url = url
instance.title = get_title(content)
instance.status = get_status(content)
instance.release_year = get_year(content)
else:
# cancel saving the instance if unable to receive web page
raise Exception('RFC not found')
Expand Down
2 changes: 1 addition & 1 deletion directory/templates/directory/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="d-flex container justify-content-center justify-sm-content-between">
<div class="flex-grow-1 text-xs-start text-lg-center align-self-center">
<div>
2017-2023 &copy; <span class="nowrap">Hans Christian Rudolph ·</span>
2017-2024 &copy; <span class="nowrap">Hans Christian Rudolph ·</span>
<span class="nowrap">Nils Grundmann</span>
</div>
<div>
Expand Down
3 changes: 1 addition & 2 deletions directory/templates/directory/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<link rel="shortcut icon" type="image/x-icon" href="{% static 'img/favicon.ico' %}">
{% compress css %}
<link rel="stylesheet" type="text/css" href="{% sass_src 'scss/custom.scss' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-icons.min.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'css/fonts.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'bootstrap/css/bootstrap-icons.min.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'css/emoji.css' %}"/>
{% endcompress %}
20 changes: 9 additions & 11 deletions directory/templates/directory/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@
<div class="col-lg-8 col-lg-offset-2 mb-2">
<h1 class="title-heading centered-text">TLS Ciphersuite Search</h1>
</div><!-- end column -->
<div class="col-lg-6 col-lg-offset-3">
<div id="custom-search-input">
<form class="form-group input-group input-group-lg" action="/search?q={{ search_form.get_search_term }}" method="get">
{{ search_form }}
<button class="btn btn-primary btn-lg" type="submit">
<div class="col-lg-8 col-lg-offset-2 mb-2">
<form action="/search?q={{ search_form.get_search_term }}" method="get">
<div class="input-group input-group-lg">
{{ search_form.q }}
<button class="btn btn-primary" type="submit">
<i class="bi bi-search"></i>
</button>
</form>
</div><!-- end end input -->
</div>
</form>
</div><!-- end column -->
</div>
<div class="row flex-row justify-content-center">
<div class="col-lg-6 col-md-offset-3">
<div class="col-lg-8 col-lg-offset-2 mb-2">
<div class="alert alert-light mt-3 centered-text" role="alert">
<i class="bi bi-info-circle-fill align-middle"></i>
<i class="bi bi-info-circle-fill align-middle" aria-hidden="true"></i>
Search for a particular cipher suite by using IANA, OpenSSL or GnuTLS name format, e.g. "<a class="alert-link break-all" href="/search/?q=TLS_DHE_DSS_WITH_AES_256_CBC_SHA256">TLS_DHE_DSS_WITH_AES_256_CBC_SHA256</a>", "<a class="alert-link break-all" href="/search/?q=DHE-DSS-AES256-SHA256">DHE-DSS-AES256-SHA256</a>", or "<a class="alert-link break-all" href="/search/?q=TLS_DHE_DSS_AES_256_CBC_SHA256">TLS_DHE_DSS_AES_256_CBC_SHA256</a>".
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion directory/templates/directory/index_cs.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="col-lg-8 col-lg-offset-2">
<h1>{{ count }} Cipher Suites</h1>
</div><!-- end column -->
<div class="col-lg-8 col-xl-offset-2">
<div class="col-lg-8 col-lg-offset-2">
{% include "directory/list_filters.html" %}
</div><!-- end column -->
</div><!-- end row -->
Expand Down
6 changes: 2 additions & 4 deletions directory/templates/directory/js.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
{% load static compress %}
{% compress js %}
<script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
{% endcompress %}
{% load static %}
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
55 changes: 28 additions & 27 deletions directory/templates/directory/navbar.html
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
{% load static %}
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<div class="container-fluid">
<a class="navbar-brand" href="/"><img src="{% static 'img/logo.png' %}" height="25"/></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNavigation" aria-controls="mainNavigation" aria-expanded="false" aria-label="Toggle navigation">

<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="mainNavigation">
<ul class="navbar-nav me-auto">
<li class="nav-item {% if navbar_context == 'cs' %}active{% endif %}">
<a class="nav-link d-flex align-items-center" href="/cs/">
<i class="bi bi-lock-fill me-1"></i>
<div class="collapse navbar-collapse" id="mainNav">
<ul class="navbar-nav me-auto">
<li class="nav-item">
<a class="nav-link d-flex align-items-center {% if navbar_context == 'cs' %}active{% endif %}" href="/cs/">
<i class="bi bi-lock-fill me-1" aria-hidden="true"></i>
Cipher Suites
</a>
</li>
<li class="nav-item {% if navbar_context == 'rfc' %}active{% endif %}">
<a class="nav-link d-flex align-items-center" href="/rfc/">
<i class="bi bi-file-earmark-lock2-fill me-1"></i>
<li class="nav-item">
<a class="nav-link d-flex align-items-center {% if navbar_context == 'rfc' %}active{% endif %}" href="/rfc/">
<i class="bi bi-file-earmark-lock2-fill me-1" aria-hidden="true"></i>
RFCs
</a>
</li>
<li class="nav-item {% if navbar_context == 'blog' %}active{% endif %}">
<a class="nav-link d-flex align-items-center" href="/blog/">
<i class="bi bi-newspaper me-1"></i>
<li class="nav-item">
<a class="nav-link d-flex align-items-center {% if navbar_context == 'blog' %}active{% endif %}" href="/blog/">
<i class="bi bi-newspaper me-1" aria-hidden="true"></i>
News
</a>
</li>
{% for page in static_pages %}
{% if page.show_in_nav %}
<li class="nav-item {% if navbar_context == page.title %}active{% endif %}">
<li class="nav-item">
{% if page.direct_link and page.content %}
<a class="nav-link d-flex align-items-center" href="{{ page.content }}" target="_blank" rel="noopener noreferrer">
{% else %}
<a class="nav-link d-flex align-items-center" href="/page/{{ page|lower }}/">
<a class="nav-link d-flex align-items-center {% if navbar_context == page.title %}active{% endif %}" href="/page/{{ page|lower }}/">
{% endif %}
{% if page.icon %}<i class="bi bi-{{ page.icon }}"></i>{% endif %}
{% if page.icon %}<i class="bi bi-{{ page.icon }}" aria-hidden="true"></i>{% endif %}
{{ page|title }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% if not hide_navbar_search %}
<form class="form-inline my-2 my-md-0" action="/search?q={{ search_form.get_search_term }}" method="get">
<div class="form-group input-group">
{{ search_form }}
<button class="btn btn-primary" type="submit">
<i class="bi bi-search"></i>
</button>
</div>
</form>
{% endif %}
</ul>
{% if not hide_navbar_search %}
<form action="/search?q={{ search_form.get_search_term }}" method="get">
<div class="input-group">
{{ search_form.q }}
<button class="btn btn-primary" type="submit">
<i class="bi bi-search"></i>
</button>
</div>
</form>
{% endif %}
</div>
</div>
</nav>
4 changes: 2 additions & 2 deletions directory/templates/directory/static_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="col-lg-8 col-lg-offset-2">
<h1>{{ static_page.title|capfirst }}</h1>
</div>
</div>

<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="col-lg-8 col-lg-offset-2">
{{ static_page.formatted_content|safe }}
</div>
</div>
Expand Down
Loading

0 comments on commit 01c94b2

Please sign in to comment.