Skip to content

Commit

Permalink
integrate changes from cmark-gfm 0.29.0.gfm.12 and gfm.13 (#61)
Browse files Browse the repository at this point in the history
* Normalize nomenclature: marker row vs. delimiter row

The code for the table extension used the term 'marker row',
but the spec calls it 'delimiter row'.

This change normalizes the terminology so that it's consistent.

* Update autolink.c

```
../../../../ext/markly/autolink.c: In function ‘postprocess_text’:
../../../../ext/markly/autolink.c:364:31: warning: passing argument 1 of ‘validate_protocol’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  364 |         if (validate_protocol("mailto:", data + start + offset + max_rewind, rewind, max_rewind)) {
      |                               ^~~~~~~~~
../../../../ext/markly/commonmark.c: In function ‘S_render_node’:
../../../../ext/markly/autolink.c:299:36: note: expected ‘char *’ but argument is of type ‘const char *’
  299 | static bool validate_protocol(char protocol[], uint8_t *data, size_t rewind, size_t max_rewind) {
      |                               ~~~~~^~~~~~~~~~
```

* Update commonmark.c

```
../../../../ext/markly/commonmark.c:405:18: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  405 |       emph_delim = "_";
      |                  ^
```

* Fix GHSL-2023-119: prevent quadratic performance by not allowing very deeply nested footnote definitions.

* Fix GHSL-2023-117: store cell index on node so that it doesn't need to be recomputed during rendering.

* Fix GHSL-2023-118: limit number of autocompleted table cells to prevent DOS.

* Expose CMARK_NODE_FOOTNOTE_DEFINION literal value.

In addition, fix a bug where the length of the literal value was
calculated AFTER the actual literal string (null terminated) was
allocated.

* Update src/node.h

Co-authored-by: Phill MV <[email protected]>

* Rename custom_int -> cell_index.

* Add newline

* Remove unnecessary scope.

* Create codeql.yml

* Changelog and version bump for 0.29.0.12

* Fix format specifier for printing a size_t

* Changelog and version bump for 0.29.0.13

* move cell index into node_cell_data

---------

Co-authored-by: Waldir Pimenta <[email protected]>
Co-authored-by: Samuel Williams <[email protected]>
Co-authored-by: Kevin Backhouse <[email protected]>
Co-authored-by: Phill MV <[email protected]>
Co-authored-by: Bas Alberts <[email protected]>
Co-authored-by: Bas Alberts <[email protected]>
  • Loading branch information
7 people authored Aug 1, 2023
1 parent b1c49eb commit 3bc2f3e
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 57 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '45 14 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'javascript', 'python', 'ruby' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
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.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


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

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(cmark-gfm)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 29)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_GFM 11)
set(PROJECT_VERSION_GFM 13)
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM})

include("FindAsan.cmake")
Expand Down
2 changes: 1 addition & 1 deletion api_test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static void test_continuation_byte(test_batch_runner *runner,

char *html =
cmark_markdown_to_html(buf, strlen(buf), CMARK_OPT_VALIDATE_UTF8);
STR_EQ(runner, html, expected, "invalid utf8 continuation byte %d/%d", pos,
STR_EQ(runner, html, expected, "invalid utf8 continuation byte %zu/%zu", pos,
len);
free(html);
}
Expand Down
12 changes: 12 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[0.29.0.gfm.13]
* Normalized marker row vs. delimiter row nomenclature (#273)
* Exposed CMARK_NODE_FOOTNOTE_DEFINITION literal value (#336)
* Fix format specifier for printing a size_t (#340)

[0.29.0.gfm.12]

* Fixed polynomial time complexity issues per
https://github.com/github/cmark-gfm/security/advisories/GHSA-w4qg-3vf7-m9x5
* Added CodeQL project integration (#337)
* Addressed const qualifier discard compiler warnings (#330, #331)

[0.29.0.gfm.11]

* Improved fixes for polynomial time complexity issues per
Expand Down
2 changes: 1 addition & 1 deletion extensions/autolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static cmark_node *match(cmark_syntax_extension *ext, cmark_parser *parser,
// inline was finished in inlines.c.
}

static bool validate_protocol(char protocol[], uint8_t *data, size_t rewind, size_t max_rewind) {
static bool validate_protocol(const char protocol[], uint8_t *data, size_t rewind, size_t max_rewind) {
size_t len = strlen(protocol);

if (len > (max_rewind - rewind)) {
Expand Down
Loading

0 comments on commit 3bc2f3e

Please sign in to comment.