Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #181

Merged
merged 160 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 159 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
279d31a
feature/automatic-csproj (#23)
nathanmartinszup Oct 1, 2020
743821d
Template email of organization invited (#22)
lucasbrunozup Oct 1, 2020
fa917ce
🔒 The screen dashboard of organization is visible something the admin…
lucasbrunozup Oct 1, 2020
2fcba06
Organizing i18n values in frontend (#30)
lucasbrunozup Oct 1, 2020
a32ab37
Removing fields type, vulnerableBellow and version from Vulnerability…
wiliansilvazup Oct 1, 2020
6a0b8df
Merge master into develop (#36)
wiliansilvazup Oct 2, 2020
67bf672
Adding company role in get all companies (#33)
nathanmartinszup Oct 2, 2020
4c5c758
Tokens of organization (#32)
lucasbrunozup Oct 2, 2020
deffae7
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 2, 2020
fdd82c7
Not found screen (#34)
lucasbrunozup Oct 2, 2020
b7dadaa
Fixing error in unique company name not necessary, and removings wron…
nathanmartinszup Oct 2, 2020
28433e3
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 2, 2020
10f0104
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 2, 2020
16ba11c
[skip ci] update versioning file
wiliansilvazup Oct 2, 2020
e86a798
Added component of pagination (#47)
lucasbrunozup Oct 5, 2020
319cbd5
CLI docker image (#25)
nathannascimentozup Oct 6, 2020
8f64f81
💅 Adjusting button dialog styles, scrollbar and select component (#48)
lucasbrunozup Oct 6, 2020
03c3387
Adjusting the texts in portugueses (#52)
lucasbrunozup Oct 9, 2020
ec41642
✅ Added option to success message from flash message component and ad…
lucasbrunozup Oct 9, 2020
6afdedf
Feature/create repository cli (#55)
nathanmartinszup Oct 14, 2020
87de822
Frontend false positive (#54)
lucasbrunozup Oct 14, 2020
8e4d121
Implementing false-positive and risk accept (#35)
wiliansilvazup Oct 14, 2020
7fd4b96
Fixing wrong text in output
wiliansilvazup Oct 14, 2020
1c4f516
Bugfix/false positive (#58)
nathanmartinszup Oct 15, 2020
7f92a44
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 15, 2020
ea71b5e
Fixing regex d34b3ba5-b988-4a0f-9344-467274cd98be (#59)
wiliansilvazup Oct 15, 2020
73fc6ad
Removing deprecated manager (#60)
wiliansilvazup Oct 15, 2020
24983bc
Fixing security pipeline in horusec (#61)
wiliansilvazup Oct 15, 2020
fd04413
Update README.md
wiliansilvazup Oct 15, 2020
130ac94
Update README.md
wiliansilvazup Oct 15, 2020
c2a047f
Change filter to receive Severity and remove Type (#64)
wiliansilvazup Oct 16, 2020
d8e90cc
Feature/improving false positive (#66)
nathanmartinszup Oct 16, 2020
ef4e5bf
[Frontend] Improvements false positive (#67)
lucasbrunozup Oct 16, 2020
9fd3313
List vulnerabilities in management screen to repository members (#68)
nathanmartinszup Oct 16, 2020
c44b702
[Frontend] - Improvements false positive (#69)
lucasbrunozup Oct 16, 2020
0d61c17
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 19, 2020
c4a75e1
Migration deploy hook (#65)
nathannascimentozup Oct 21, 2020
695456c
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 21, 2020
966f161
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 22, 2020
683f0db
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 22, 2020
416f271
Adding api to delete account and permissions (#85)
nathanmartinszup Oct 26, 2020
7cdfddb
Merge branch 'develop' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 26, 2020
5fb9e93
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 26, 2020
3bf7a2b
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 26, 2020
5c6cbce
Feature/horusec auth (#62)
nathanmartinszup Oct 27, 2020
e73635c
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 27, 2020
0b32405
Frontend - Many authentication types (#77)
lucasbrunozup Oct 27, 2020
1d0a5a6
🇺🇸 Translate e-mail templates to english (#95)
lucasbrunozup Oct 28, 2020
11ad59f
Feature/application admin (#86)
nathanmartinszup Oct 28, 2020
933cc17
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Oct 28, 2020
25c2b64
Adding return content when create account from keycloak (#98)
wiliansilvazup Oct 28, 2020
f28d36b
Frontend admin application (#100)
lucasbrunozup Oct 29, 2020
7746e1a
[WIP] Feature/improving test (#99)
wiliansilvazup Oct 29, 2020
a21b14b
🛠 Fixing method to verify admin application (#111)
lucasbrunozup Nov 4, 2020
be606b2
Frontend environments in compose files (#110)
lucasbrunozup Nov 5, 2020
8d4d463
Feature/auth grpc (#112)
nathanmartinszup Nov 6, 2020
fac397a
Feature/improving test (#102)
wiliansilvazup Nov 6, 2020
ee5c8cf
Merge master into develop
wiliansilvazup Nov 6, 2020
83152a0
Fixing keycloak compose e2e
wiliansilvazup Nov 6, 2020
eaf32fe
[WIP] Ldap auth service integration (#71)
nathannascimentozup Nov 6, 2020
4069ed6
Adding validation to horusec login errors (#118)
nathanmartinszup Nov 9, 2020
10b98ce
[WIP] Fixing e2e (#115)
wiliansilvazup Nov 9, 2020
11df8b3
Fixing repository authz groups (#116)
nathannascimentozup Nov 9, 2020
206097f
Fixing compose content
wiliansilvazup Nov 9, 2020
9e5e701
Removing minimum version and adding version recommendation message (#…
nathanmartinszup Nov 9, 2020
35028e9
Merge master into develop
wiliansilvazup Nov 9, 2020
e061705
feature/auth-account-operations (#122)
nathanmartinszup Nov 11, 2020
ff9e20e
Adjusting to view field of email to app admin when create new organiz…
wiliansilvazup Nov 11, 2020
7b1d2e2
Improving cli to print error message by line, and removing missing pa…
nathanmartinszup Nov 11, 2020
abd96b6
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Nov 11, 2020
bbec834
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Nov 12, 2020
96195df
Feature/semgrep (#128)
nathanmartinszup Nov 13, 2020
cd3a237
feature choice-tool (#132)
wiliansilvazup Nov 13, 2020
30924b0
Feature/webhook (#113)
wiliansilvazup Nov 13, 2020
560d962
[Frontend] Webhook (#117)
lucasbrunozup Nov 13, 2020
562cd27
Fixing auth cors (#133)
nathannascimentozup Nov 13, 2020
1445845
Update account username and email (#135)
nathannascimentozup Nov 17, 2020
b7ff02a
Repository form authz groups (#134)
nathannascimentozup Nov 17, 2020
025d2c1
Update pt-br.json (#139)
GleytonLima Nov 18, 2020
5123745
Feature/horusec-csharp (#131)
nathanmartinszup Nov 18, 2020
6303178
Removing Landing Page (#141)
wiliansilvazup Nov 18, 2020
5c662a1
Adding eslint dockerfile
nathannascimentozup Nov 18, 2020
57d23ba
Merge branch 'master' into develop
wiliansilvazup Nov 18, 2020
83e9075
Change name dotnet to csharp (#144)
wiliansilvazup Nov 18, 2020
9ce9933
WIP adding eslint formatter
nathannascimentozup Nov 18, 2020
1730645
Update version csharp
wiliansilvazup Nov 18, 2020
caec155
WIP cleanup formatter code
nathannascimentozup Nov 18, 2020
42cdede
Wip adding eslint formatter docker execution
nathannascimentozup Nov 18, 2020
bca0af5
Adding analyser eslint formatter
nathannascimentozup Nov 18, 2020
100f890
Fixing eslint configuration
nathannascimentozup Nov 18, 2020
27a6c9c
Adding eslint security rules config
nathannascimentozup Nov 18, 2020
2c0437a
Improving eslint formatter
nathannascimentozup Nov 18, 2020
e48c879
Adding eslint output struct
nathannascimentozup Nov 18, 2020
033e741
Adding eslint results into analysis
nathannascimentozup Nov 18, 2020
f8074b2
Adding eslint javascript analyse
nathannascimentozup Nov 18, 2020
fa1638c
Merge branch 'develop' into feature/eslint-sec-scan
wiliansilvazup Nov 19, 2020
b375bc1
Feature/update docs (#140)
wiliansilvazup Nov 19, 2020
cac4bda
Adding estlint image script
nathannascimentozup Nov 19, 2020
b0501c3
Adding eslint tool in deploy workflow
nathannascimentozup Nov 19, 2020
cbb4fd0
Fixing eslint tool name
nathannascimentozup Nov 19, 2020
f9863b3
Merge branch 'feature/eslint-sec-scan' of github.com:ZupIT/horusec in…
nathannascimentozup Nov 19, 2020
a0e0f5a
Updating ignore tool flag description
nathannascimentozup Nov 19, 2020
e9665a1
Merge branch 'develop' of github.com:ZupIT/horusec into feature/eslin…
nathannascimentozup Nov 19, 2020
aee916b
Fixing lint problem
nathannascimentozup Nov 19, 2020
878fe69
Fixing eslint file pattern
nathannascimentozup Nov 19, 2020
65a1598
Testing eslint formatter
nathannascimentozup Nov 19, 2020
bad775e
Testing eslint formatter
nathannascimentozup Nov 19, 2020
d39f204
Adding eslint scan in readme
nathannascimentozup Nov 19, 2020
f793bb1
Fixing code sample length
nathannascimentozup Nov 19, 2020
253bc92
Fixing eslint config
nathannascimentozup Nov 19, 2020
d9578cd
Removing eslint object injection
nathannascimentozup Nov 19, 2020
c5a8d16
Feature/horusec nodejs (#143)
wiliansilvazup Nov 19, 2020
82107f3
Feature/k8s cli (#148)
nathanmartinszup Nov 19, 2020
e8aeb11
Update deploy-cli-tools.yml
wiliansilvazup Nov 20, 2020
cc264df
Update update-image-tool.sh
wiliansilvazup Nov 20, 2020
b2f0a9e
Adding docs kubernetes (#149)
wiliansilvazup Nov 20, 2020
4d4401b
Adding eslint in analysis slice
nathannascimentozup Nov 20, 2020
494e166
Fixing eslint config
nathannascimentozup Nov 20, 2020
6fca17c
Merge branch 'develop' of github.com:ZupIT/horusec into feature/eslin…
nathannascimentozup Nov 20, 2020
06e32e2
Javascritpt eslint security (#146)
nathannascimentozup Nov 20, 2020
4208a1a
Fixing eslint extensions
nathannascimentozup Nov 20, 2020
ef11c98
Merge branch 'develop' of github.com:ZupIT/horusec into develop
nathannascimentozup Nov 20, 2020
25f2ce3
Fixing eslint file paht
nathannascimentozup Nov 20, 2020
131f135
Fixing generics bugs (#150)
wiliansilvazup Nov 20, 2020
0d91598
Downgrade severity no use localstorage
wiliansilvazup Nov 20, 2020
b8efe45
Adding files license
nathannascimentozup Nov 20, 2020
aac63a9
Merge branch 'develop' of github.com:ZupIT/horusec into develop
nathannascimentozup Nov 20, 2020
d210cec
Adding yaml license
nathannascimentozup Nov 20, 2020
a01ca75
Added INFO severity and add colors of languages (#152)
lucasbrunozup Nov 20, 2020
742f641
Update README.md
wiliansilvazup Nov 23, 2020
ed3902e
[skip ci] update versioning file
wiliansilvazup Nov 23, 2020
b356506
[skip ci] update versioning file
wiliansilvazup Nov 23, 2020
e81ef48
[skip ci] update versioning file
wiliansilvazup Nov 23, 2020
3a43937
Merge with master
wiliansilvazup Nov 24, 2020
8e6f8d3
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Nov 24, 2020
6abb0e4
Adding vulnerabilities tests for horusec-leaks rules (#158)
wiliansilvazup Nov 27, 2020
1004304
Adding project path in file with vulnerability (#156)
wiliansilvazup Nov 27, 2020
1e4cf21
Fix Reset password validation (#160)
wiliansilvazup Nov 27, 2020
e60c49e
[Frontend] Webhook improvements (#136)
lucasbrunozup Nov 27, 2020
6544466
Adding validation for get password correctly
wiliansilvazup Nov 27, 2020
f2e91cf
Adding validation for get password correctly
wiliansilvazup Nov 27, 2020
7345378
Bugfix/update account (#166)
wiliansilvazup Nov 30, 2020
5bd928f
Adding stable version to migrate (#167) (#168)
nathanmartinszup Nov 30, 2020
3bfd25d
Updating develop with master (#170)
nathanmartinszup Dec 1, 2020
796a8e7
Squashed commit of the following:
wiliansilvazup Dec 2, 2020
b5c7805
Merge branch 'develop' of github.com:ZupIT/horusec into develop
wiliansilvazup Dec 2, 2020
67d7d68
Settings screen (#137)
lucasbrunozup Dec 2, 2020
d442f2c
Merge with master
wiliansilvazup Dec 2, 2020
2405ab2
Feature/flawfinder (#171)
nathanmartinszup Dec 3, 2020
7cd0d6b
Update README.md
wiliansilvazup Dec 3, 2020
e01eb94
Added rules when the the option of broker service is disabled in back…
lucasbrunozup Dec 7, 2020
5b09d6e
Feature/phpcs (#177)
nathanmartinszup Dec 7, 2020
6a92079
Bugfix/improving-grpc-logs (#178)
nathanmartinszup Dec 7, 2020
a1c1bc9
Fixing error when load the donut chart with empty data (#179)
lucasbrunozup Dec 8, 2020
8e3769e
Merge branch 'master' of github.com:ZupIT/horusec into develop
wiliansilvazup Dec 8, 2020
ecb4b12
Add headers dynamic to send on request (#182)
wiliansilvazup Dec 8, 2020
d04398b
Updating Authorization header to X-Horusec-Authorization (#183)
nathanmartinszup Dec 8, 2020
7dfd413
Adjusting colors of svg icons and add new webhook icon (#184)
lucasbrunozup Dec 8, 2020
8da6ead
Fixing clear inputs when create new webhook (#185)
lucasbrunozup Dec 8, 2020
fb83616
[skip ci] update versioning file
wiliansilvazup Dec 8, 2020
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ coverage-horusec-analytic:
deployments/scripts/coverage.sh 98 "./horusec-analytic"
coverage-horusec-auth:
chmod +x deployments/scripts/coverage.sh
deployments/scripts/coverage.sh 97 "./horusec-auth"
deployments/scripts/coverage.sh 96 "./horusec-auth"
coverage-horusec-webhook:
chmod +x deployments/scripts/coverage.sh
deployments/scripts/coverage.sh 99 "./horusec-webhook"
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ Currently, performance analysis consists of:
* [GitLeaks][Gitleaks]
* PHP
* [Semgrep][Semgrep]
* C
* [PHPCS][PHPCS]
* C/C++
* [Semgrep][Semgrep]
* [Flawfinder][Flawfinder]
* HTML
* [Semgrep][Semgrep]
* JSON
Expand Down Expand Up @@ -185,3 +187,5 @@ This project exists thanks to all the [contributors]((https://github.com/ZupIT/h
[SecuriyCodeScan]: https://security-code-scan.github.io/
[Semgrep]: https://github.com/returntocorp/semgrep
[EsLint]: https://github.com/eslint/eslint
[Flawfinder]: https://github.com/david-a-wheeler/flawfinder
[PHPCS]: https://github.com/FloeDesignTechnologies/phpcs-security-audit
4 changes: 4 additions & 0 deletions deployments/dockerfiles/flawfinder/.semver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alpha: 0
beta: 0
rc: 0
release: v0.0.1
18 changes: 18 additions & 0 deletions deployments/dockerfiles/flawfinder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
#
# 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.

FROM python:3.7-alpine

RUN apk add --no-cache git bash
RUN pip install flawfinder
4 changes: 4 additions & 0 deletions deployments/dockerfiles/phpcs/.semver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alpha: 0
beta: 0
rc: 0
release: v0.0.1
25 changes: 25 additions & 0 deletions deployments/dockerfiles/phpcs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
#
# 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.

FROM php:7.4-alpine

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN composer global config bin-dir /usr/local/bin

RUN composer global require "squizlabs/php_codesniffer=*"

RUN composer require --dev pheromone/phpcs-security-audit

RUN phpcs --config-set installed_paths /vendor/pheromone/phpcs-security-audit/Security
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type IAccount interface {
GetByAccountID(accountID uuid.UUID) (*authEntities.Account, error)
GetByEmail(email string) (*authEntities.Account, error)
Update(account *authEntities.Account) error
UpdatePassword(account *authEntities.Account) error
GetByUsername(username string) (*authEntities.Account, error)
DeleteAccount(accountID uuid.UUID) error
}
Expand Down Expand Up @@ -61,7 +62,13 @@ func (a *Account) GetByEmail(email string) (*authEntities.Account, error) {

func (a *Account) Update(account *authEntities.Account) error {
account.SetUpdatedAt()
return a.databaseWrite.Update(account.ToMap(), map[string]interface{}{"account_id": account.AccountID},
return a.databaseWrite.Update(account.ToUpdateMap(), map[string]interface{}{"account_id": account.AccountID},
account.GetTable()).GetError()
}

func (a *Account) UpdatePassword(account *authEntities.Account) error {
account.SetUpdatedAt()
return a.databaseWrite.Update(account.ToUpdatePasswordMap(), map[string]interface{}{"account_id": account.AccountID},
account.GetTable()).GetError()
}

Expand Down
4 changes: 2 additions & 2 deletions development-kit/pkg/engines/leaks/analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestAnalysis_StartAnalysis(t *testing.T) {
data := []engine.Finding{}
_ = json.Unmarshal(fileBytes, &data)
assert.NoError(t, os.RemoveAll(configs.GetOutputFilePath()))
assert.Equal(t, len(data), 17)
assert.Equal(t, len(data), 19)
})
t.Run("Should return success when read analysis and return two vulnerabilities", func(t *testing.T) {
configs := config.NewConfig()
Expand Down Expand Up @@ -117,6 +117,6 @@ func TestAnalysis_StartRegularAnalysis(t *testing.T) {
vulnCounter++
}
}
assert.Equal(t, vulnCounter, 10)
assert.Equal(t, 12, vulnCounter)
})
}
54 changes: 54 additions & 0 deletions development-kit/pkg/entities/analyser/c/result.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
//
// 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 c

import (
"fmt"
"github.com/ZupIT/horusec/development-kit/pkg/enums/severity"
"strconv"
"strings"
)

type Result struct {
File string `json:"file"`
Line string `json:"line"`
Column string `json:"column"`
Level string `json:"level"`
Warning string `json:"warning"`
Suggestion string `json:"suggestion"`
Note string `json:"note"`
Context string `json:"context"`
}

func (r *Result) GetDetails() string {
return fmt.Sprintf("%s %s %s", r.Warning, r.Suggestion, r.Note)
}

func (r *Result) GetSeverity() severity.Severity {
level, _ := strconv.Atoi(r.Level)
if level <= 2 {
return severity.Low
}

if level >= 3 && level <= 4 {
return severity.Medium
}

return severity.High
}

func (r *Result) GetFilename() string {
return strings.ReplaceAll(r.File, "./", "")
}
82 changes: 82 additions & 0 deletions development-kit/pkg/entities/analyser/c/result_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package c

import (
"github.com/ZupIT/horusec/development-kit/pkg/enums/severity"
"github.com/stretchr/testify/assert"
"testing"
)

func TestGetDetails(t *testing.T) {
result := &Result{
Warning: "test",
Suggestion: "test",
Note: "test",
}

t.Run("should success get details", func(t *testing.T) {
details := result.GetDetails()

assert.NotEmpty(t, details)
assert.Equal(t, "test test test", details)
})

}

func TestGetSeverity(t *testing.T) {
result := &Result{
Level: "0",
}

t.Run("should get severity low", func(t *testing.T) {
assert.Equal(t, severity.Low, result.GetSeverity())

result.Level = "1"
assert.Equal(t, severity.Low, result.GetSeverity())

result.Level = "2"
assert.Equal(t, severity.Low, result.GetSeverity())
})

t.Run("should get severity medium", func(t *testing.T) {
result.Level = "3"
assert.Equal(t, severity.Medium, result.GetSeverity())

result.Level = "4"
assert.Equal(t, severity.Medium, result.GetSeverity())

result.Level = "2"
assert.NotEqual(t, severity.Medium, result.GetSeverity())

result.Level = "5"
assert.NotEqual(t, severity.Medium, result.GetSeverity())
})

t.Run("should get severity high", func(t *testing.T) {
result.Level = "5"
assert.Equal(t, severity.High, result.GetSeverity())

result.Level = "6"
assert.Equal(t, severity.High, result.GetSeverity())

result.Level = "1"
assert.NotEqual(t, severity.High, result.GetSeverity())

result.Level = "4"
assert.NotEqual(t, severity.High, result.GetSeverity())
})
}

func TestGetFilename(t *testing.T) {
result := &Result{
File: "./test.c",
}

t.Run("should success get filename", func(t *testing.T) {
filename := result.GetFilename()

assert.NotEmpty(t, filename)
assert.NotContains(t, filename, "./")
assert.Equal(t, "test.c", filename)
})

}
26 changes: 26 additions & 0 deletions development-kit/pkg/entities/analyser/php/phpcs/message.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package phpcs

import (
"strconv"
"strings"
)

type Message struct {
Message string `json:"message"`
Line int `json:"line"`
Column int `json:"column"`
Type string `json:"type"`
}

func (m *Message) GetLine() string {
return strconv.Itoa(m.Line)
}

func (m *Message) GetColumn() string {
return strconv.Itoa(m.Column)
}

func (m *Message) IsValidMessage() bool {
return m.Type == "ERROR" &&
!strings.Contains(m.Message, "This implies that some PHP code is not scanned by PHPCS")
}
52 changes: 52 additions & 0 deletions development-kit/pkg/entities/analyser/php/phpcs/message_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package phpcs

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestGetLine(t *testing.T) {
message := &Message{
Line: 1,
}

t.Run("should success get line", func(t *testing.T) {
line := message.GetLine()

assert.NotEmpty(t, line)
assert.Equal(t, "1", line)
})
}

func TestGetColumn(t *testing.T) {
message := &Message{
Column: 1,
}

t.Run("should success get column", func(t *testing.T) {
column := message.GetColumn()

assert.NotEmpty(t, column)
assert.Equal(t, "1", column)
})
}

func TestIsValidMessage(t *testing.T) {
t.Run("should return false if invalid message", func(t *testing.T) {
message := &Message{
Message: "This implies that some PHP code is not scanned by PHPCS",
Type: "ERROR",
}

assert.False(t, message.IsValidMessage())
})

t.Run("should return true if valid message", func(t *testing.T) {
message := &Message{
Message: "",
Type: "ERROR",
}

assert.True(t, message.IsValidMessage())
})
}
5 changes: 5 additions & 0 deletions development-kit/pkg/entities/analyser/php/phpcs/result.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package phpcs

type Result struct {
Messages []Message `json:"messages"`
}
15 changes: 15 additions & 0 deletions development-kit/pkg/entities/auth/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ func (a *Account) ToMap() map[string]interface{} {
}
}

func (a *Account) ToUpdateMap() map[string]interface{} {
return map[string]interface{}{
"email": a.Email,
"username": a.Username,
"updated_at": a.UpdatedAt,
"is_confirmed": a.IsConfirmed,
}
}

func (a *Account) ToUpdatePasswordMap() map[string]interface{} {
return map[string]interface{}{
"password": a.Password,
}
}

func (a *Account) IsNotApplicationAdminAccount() bool {
return !a.IsApplicationAdmin
}
Loading