domain

package
v0.0.66 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package domain contains the domain logic for the homoglyphs rule type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HomoglyphProcessor

type HomoglyphProcessor interface {
	FindViolations(line string) []*Violation
	GetSubCommentText() string
	GetLineCommentText(violation *Violation) string
	GetPassedReviewText() string
	GetFailedReviewText() string
}

HomoglyphProcessor is an interface for a homoglyph processor

func NewInvisibleCharactersProcessor

func NewInvisibleCharactersProcessor() HomoglyphProcessor

NewInvisibleCharactersProcessor creates a new InvisibleCharactersProcessor

func NewMixedScriptsProcessor

func NewMixedScriptsProcessor(ctx context.Context) (HomoglyphProcessor, error)

NewMixedScriptsProcessor creates a new MixedScriptsProcessor

type InvisibleCharactersProcessor

type InvisibleCharactersProcessor struct {
	// contains filtered or unexported fields
}

InvisibleCharactersProcessor is a processor for the invisible characters rule type

func (*InvisibleCharactersProcessor) FindInvisibleCharacters

func (ice *InvisibleCharactersProcessor) FindInvisibleCharacters(line string) []*Violation

FindInvisibleCharacters checks for invisible characters in the given line and returns a slice of runes representing the invisible characters found.

func (*InvisibleCharactersProcessor) FindViolations

func (ice *InvisibleCharactersProcessor) FindViolations(line string) []*Violation

FindViolations finds invisible characters in the given line

func (*InvisibleCharactersProcessor) GetFailedReviewText

func (_ *InvisibleCharactersProcessor) GetFailedReviewText() string

GetFailedReviewText returns the failed review text for invisible characters

func (*InvisibleCharactersProcessor) GetLineCommentText

func (_ *InvisibleCharactersProcessor) GetLineCommentText(violation *Violation) string

GetLineCommentText returns the line comment text for invisible characters

func (*InvisibleCharactersProcessor) GetPassedReviewText

func (_ *InvisibleCharactersProcessor) GetPassedReviewText() string

GetPassedReviewText returns the passed review text for invisible characters

func (*InvisibleCharactersProcessor) GetSubCommentText

func (_ *InvisibleCharactersProcessor) GetSubCommentText() string

GetSubCommentText returns the sub comment text for invisible characters

type MixedScriptInfo

type MixedScriptInfo struct {
	Text         string
	ScriptsFound []string
}

MixedScriptInfo contains information about a word that mixes multiple scripts

type MixedScriptsProcessor

type MixedScriptsProcessor struct {
	// contains filtered or unexported fields
}

MixedScriptsProcessor is a processor for the mixed scripts rule type

func (*MixedScriptsProcessor) FindMixedScripts

func (mse *MixedScriptsProcessor) FindMixedScripts(line string) []*Violation

FindMixedScripts returns a slice of MixedScriptInfo for words in the input string that mix multiple scripts, ignoring common characters, detecting potential obfuscation in text. Words with only common script characters are not flagged. E.g. “B. C“ is not considered mixed-scripts by default: it contains characters from Latin and Common, but Common is excluded by default.

func (*MixedScriptsProcessor) FindViolations

func (mse *MixedScriptsProcessor) FindViolations(line string) []*Violation

FindViolations finds mixed scripts in the given line

func (*MixedScriptsProcessor) GetFailedReviewText

func (_ *MixedScriptsProcessor) GetFailedReviewText() string

GetFailedReviewText returns the failed review text for mixed scripts

func (*MixedScriptsProcessor) GetLineCommentText

func (_ *MixedScriptsProcessor) GetLineCommentText(violation *Violation) string

GetLineCommentText returns the line comment text for mixed scripts

func (*MixedScriptsProcessor) GetPassedReviewText

func (_ *MixedScriptsProcessor) GetPassedReviewText() string

GetPassedReviewText returns the passed review text for mixed scripts

func (*MixedScriptsProcessor) GetSubCommentText

func (_ *MixedScriptsProcessor) GetSubCommentText() string

GetSubCommentText returns the sub comment text for mixed scripts

type Violation

type Violation struct {
	// InvisibleChar an invisible character found in a line.
	InvisibleChar rune

	// mixedScript is a mixed script found in a line.
	MixedScript *MixedScriptInfo
}

Violation contains the result of a homoglyph violation

Directories

Path Synopsis
Package resources contains resources used by the homoglyphs evaluators.
Package resources contains resources used by the homoglyphs evaluators.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL