Documentation
¶
Overview ¶
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.
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.
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.
Index ¶
Constants ¶
const ( RuleMapBuiltMsg = "building rules map" CompileYaraRuleFailedMsg = "Mole could not compile a yara rule, because" YaraRuleMetadataMsg = "while getting metadata info from %s got" AddingRuleMsg = "adding rule: proto:%s | src:%s | sport:%s | dst:%s | dport:%s" InsertRuleFailedMsg = "unable to insert rule %s, because" NewYaraCompilerMsg = "while creating yara compiler got" CompiledRulesNotFoundMsg = "unable to get compiled rules" WhileGettingNodeByTypeMsg = "while getting node by type got" DecisionTreeNotInitMsg = "decision tree not initialized" CreateTreeNodeAtLevelMsg = "when creating node at level %d with key %s got" SolutionNotFoundMsg = "solution not found" BactrackWithNilNode = "backtracking does not work with nil nodes" )
Variables ¶
var ( ErrCompiledRulesNotFound = errors.New(CompiledRulesNotFoundMsg) ErrDecisionTreeNotInit = errors.New(DecisionTreeNotInitMsg) ErrSolutionNotFound = errors.New(SolutionNotFoundMsg) )
Functions ¶
Types ¶
type Bactracking ¶
type Bactracking struct {
// contains filtered or unexported fields
}
Bactracking implements the backtracking search
func NewBactracking ¶
func NewBactracking(target types.MetaRule) *Bactracking
NewBactracking returns a new Backtracking object. The argument is the target to search for
func (*Bactracking) Accepted ¶
func (bt *Bactracking) Accepted(node nodes.NodeValue) bool
Accepted check whether the NodeValue is a good candidate for the solution
func (*Bactracking) AddPartial ¶
func (bt *Bactracking) AddPartial(node nodes.NodeValue)
AddPartial adds partial solution using the NodeValue
func (*Bactracking) Backtrack ¶
func (bt *Bactracking) Backtrack(node *Tree)
Backtrack performs the search
func (*Bactracking) GetResult ¶
func (bt *Bactracking) GetResult() []string
GetResult returns the identifier from the `id` node
func (*Bactracking) Solution ¶
func (bt *Bactracking) Solution() bool
Solution returns whether the algorithm has a soluiton
type Tree ¶
type Tree struct { // Value is the node's value Value nodes.NodeValue // Parent points to the parent node Parent *Tree // Next points to the next node in the same lavel Next *Tree // Children point to the child node and so the next level in the tree Children *Tree }
Tree implemnts a n-ary tree for storing the decision tree
var ( // Decision is the decision tree Decision *Tree )
func GetNodeByType ¶
GetNodeByType returns a node based on the type of node
func InsertRule ¶
InsertRule inserts Yara rule and generates an ID