Skip to content

Commit

Permalink
MEDIUM: add harden,thread-hard-limit,ssl-security-level,http-err-code…
Browse files Browse the repository at this point in the history
…s, http-fail-codes keywords

Add:
- harden.reject-privileged-ports.quic
- harden.reject-privileged-ports.tcp
- thread-hard-limit
- ssl-security-level keywords
- http-err-codes
- http-fail-codes
  • Loading branch information
hdurand0710 committed Jun 19, 2024
1 parent 4f80f1b commit 1217c4e
Show file tree
Hide file tree
Showing 12 changed files with 844 additions and 0 deletions.
64 changes: 64 additions & 0 deletions parsers/http-err-codes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

157 changes: 157 additions & 0 deletions parsers/http-err-codes_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

157 changes: 157 additions & 0 deletions parsers/http-err-codes_generated.go.sav
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// Code generated by go generate; DO NOT EDIT.
/*
Copyright 2019 HAProxy Technologies

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package parsers

import (
"github.com/haproxytech/config-parser/v5/common"
"github.com/haproxytech/config-parser/v5/errors"
"github.com/haproxytech/config-parser/v5/types"
)

func (p *HTTPErrCodes) Init() {
p.data = []types.HTTPErrCodes{}
p.preComments = []string{}
}

func (p *HTTPErrCodes) GetParserName() string {
return "http-err-codes"
}

func (p *HTTPErrCodes) Get(createIfNotExist bool) (common.ParserData, error) {
if len(p.data) == 0 && !createIfNotExist {
return nil, errors.ErrFetch
}
return p.data, nil
}

func (p *HTTPErrCodes) GetPreComments() ([]string, error) {
return p.preComments, nil
}

func (p *HTTPErrCodes) SetPreComments(preComments []string) {
p.preComments = preComments
}

func (p *HTTPErrCodes) GetOne(index int) (common.ParserData, error) {
if index < 0 || index >= len(p.data) {
return nil, errors.ErrFetch
}
return p.data[index], nil
}

func (p *HTTPErrCodes) Delete(index int) error {
if index < 0 || index >= len(p.data) {
return errors.ErrFetch
}
copy(p.data[index:], p.data[index+1:])
p.data[len(p.data)-1] = types.HTTPErrCodes{}
p.data = p.data[:len(p.data)-1]
return nil
}

func (p *HTTPErrCodes) Insert(data common.ParserData, index int) error {
if data == nil {
return errors.ErrInvalidData
}
switch newValue := data.(type) {
case []types.HTTPErrCodes:
p.data = newValue
case *types.HTTPErrCodes:
if index > -1 {
if index > len(p.data) {
return errors.ErrIndexOutOfRange
}
p.data = append(p.data, types.HTTPErrCodes{})
copy(p.data[index+1:], p.data[index:])
p.data[index] = *newValue
} else {
p.data = append(p.data, *newValue)
}
case types.HTTPErrCodes:
if index > -1 {
if index > len(p.data) {
return errors.ErrIndexOutOfRange
}
p.data = append(p.data, types.HTTPErrCodes{})
copy(p.data[index+1:], p.data[index:])
p.data[index] = newValue
} else {
p.data = append(p.data, newValue)
}
default:
return errors.ErrInvalidData
}
return nil
}

func (p *HTTPErrCodes) Set(data common.ParserData, index int) error {
if data == nil {
p.Init()
return nil
}
switch newValue := data.(type) {
case []types.HTTPErrCodes:
p.data = newValue
case *types.HTTPErrCodes:
if index > -1 && index < len(p.data) {
p.data[index] = *newValue
} else if index == -1 {
p.data = append(p.data, *newValue)
} else {
return errors.ErrIndexOutOfRange
}
case types.HTTPErrCodes:
if index > -1 && index < len(p.data) {
p.data[index] = newValue
} else if index == -1 {
p.data = append(p.data, newValue)
} else {
return errors.ErrIndexOutOfRange
}
default:
return errors.ErrInvalidData
}
return nil
}

func (p *HTTPErrCodes) PreParse(line string, parts []string, preComments []string, comment string) (string, error) {
changeState, err := p.Parse(line, parts, comment)
if err == nil && preComments != nil {
p.preComments = append(p.preComments, preComments...)
}
return changeState, err
}

func (p *HTTPErrCodes) Parse(line string, parts []string, comment string) (string, error) {
if parts[0] == "http-err-codes" {
data, err := p.parse(line, parts, comment)
if err != nil {
if _, ok := err.(*errors.ParseError); ok {
return "", err
}
return "", &errors.ParseError{Parser: "HTTPErrCodes", Line: line}
}
p.data = append(p.data, *data)
return "", nil
}
return "", &errors.ParseError{Parser: "HTTPErrCodes", Line: line}
}

func (p *HTTPErrCodes) ResultAll() ([]common.ReturnResultLine, []string, error) {
res, err := p.Result()
return res, p.preComments, err
}
Loading

0 comments on commit 1217c4e

Please sign in to comment.