Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

---
ci:
autofix_commit_msg: |
Expand Down
4 changes: 4 additions & 0 deletions listener.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Copyright 2025 OWASP CRS Project
// SPDX-License-Identifier: Apache-2.0

package main

import (
"fmt"
"strconv"

"github.com/antlr4-go/antlr/v4"

"github.com/coreruleset/seclang_parser/parser"
)

Expand Down
2 changes: 1 addition & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Format() error {
// addlicense strangely logs skipped files to stderr despite not being erroneous, so use the long sh.Exec form to
// discard stderr too.
if _, err := sh.Exec(map[string]string{}, io.Discard, io.Discard, "go", "run", fmt.Sprintf("github.com/google/addlicense@%s", addLicenseVersion),
"-c", "Felipe Zipitria",
"-c", "OWASP CRS Project",
"-s=only",
"-ignore", "**/*.yml",
"-ignore", "**/*.g4",
Expand Down
3 changes: 2 additions & 1 deletion parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"testing"

"github.com/antlr4-go/antlr/v4"
"github.com/coreruleset/seclang_parser/parser"
"github.com/stretchr/testify/require"

"github.com/coreruleset/seclang_parser/parser"
)

var crsTestFiles = []string{
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/SecLangLexer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

# Generated from SecLangLexer.g4 by ANTLR 4.13.2
from antlr4 import *
from io import StringIO
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/SecLangParser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

# Generated from SecLangParser.g4 by ANTLR 4.13.2
# encoding: utf-8
from antlr4 import *
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/SecLangParserListener.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

# Generated from SecLangParser.g4 by ANTLR 4.13.2
from antlr4 import *
if "." in __name__:
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

3 changes: 3 additions & 0 deletions src/seclang_parser/actions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

class Action:
def __init__(self, action, param=None):
self.action = action
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

"""Command-line interface for the CRS parser."""

import argparse
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/configuration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

class Configuration:
def __init__(self, marker=None, directives=None):
self.marker = marker
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/directives.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

from .actions import SeclangActions
from .metadata import SecRuleMetadata
from .operators import Operator
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

from antlr4.error.ErrorListener import ErrorListener
from antlr4.error.Errors import ParseCancellationException

Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

class CommentMetadata:
def __init__(self, comment=None):
self.comment = comment
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/operators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

class Operator:
def __init__(self, name='', value=''):
self.name = name
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

from antlr4 import *

from .SecLangLexer import SecLangLexer
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/transformations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

class Transformations:
def __init__(self):
self.transformations = []
Expand Down
3 changes: 3 additions & 0 deletions src/seclang_parser/variables.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

class Variables:
def __init__(self):
self.variables = []
Expand Down
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

# -*- coding: utf-8 -*-
import glob

Expand Down
3 changes: 3 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

import sys

from seclang_parser.cli import run
Expand Down
3 changes: 3 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2025 OWASP CRS Project
# SPDX-License-Identifier: Apache-2.0

import sys

from antlr4 import *
Expand Down