Skip to content

Commit

Permalink
Added comments and changed file tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cx-henriqueAlvelos committed Aug 8, 2023
1 parent 902a569 commit 98ff2c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/parser/ansible/ini/config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/Checkmarx/kics/pkg/model"
"github.com/Checkmarx/kics/pkg/parser/ansible/ini/comments"
"github.com/bigkevmcd/go-configparser"
)

Expand All @@ -31,9 +32,9 @@ func (p *Parser) Parse(filePath string, fileContent []byte) ([]model.Document, [
doc := make(map[string]interface{})
doc["groups"] = refactorConfig(config)

// TODO: GET IGNOREDLINES
ignoreLines := comments.GetIgnoreLines(strings.Split(string(fileContent), "\n"))

return []model.Document{doc}, []int{}, nil
return []model.Document{doc}, ignoreLines, nil
}

// refactorConfig removes all extra information and tries to convert
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/analyzer_test/ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#CFG File test
[defaults]
action_warnings=True
cowsay_enabled_stencils=bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in-snake, elephant, eyes, hellokitty, kitty, luke-koala, meow, milk, moofasa, moose, ren, sheep, small, stegosaurus, stimpy, supermilker, three-eyes, turkey, turtle, tux, udder, vader-koala, vader, www
Expand Down Expand Up @@ -83,6 +84,7 @@ invalid_task_attribute_failed=True
jinja2_native_warning=True
localhost_warning=True
max_diff_size=104448
;module_ignore_exts
module_ignore_exts={{(REJECT_EXTS + ('.yaml', '.yml', '.ini'))}}
network_group_modules=eos, nxos, ios, iosxr, junos, enos, ce, vyos, sros, dellos9, dellos10, dellos6, asa, aruba, aireos, bigip, ironware, onyx, netconf, exos, voss, slxos
old_plugin_cache_clear=False
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/analyzer_test/ansible.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Configuration file test
[defaults]
inventory = /etc/ansible/hosts
library = /usr/share/ansible/
Expand All @@ -8,6 +9,7 @@ stdout_callback = yaml
forks = 10
strategy = free

; ssh_connection
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ControlPath=/tmp/ansible-ssh-%h-%p-%r
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/analyzer_test/hosts.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@


# File test
[webservers]
webserver1 ansible_host=192.168.1.100
webserver2 ansible_host=192.168.1.101
sa
webserver3 ansible_host=192.168.1.102

; Testing Also Comments
[webservers:vars]
http_port=80
app_env=production
Expand Down

0 comments on commit 98ff2c3

Please sign in to comment.