Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/sensu/uchiwa
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoizat committed Mar 5, 2018
2 parents 0f29551 + df6fd73 commit 091e808
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 63 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: true
language: go
go:
- 1.8
- 1.9
env:
matrix:
- TRAVIS_GOOS=linux TRAVIS_GOARCH=386
Expand All @@ -10,18 +10,13 @@ env:
- AWS_REGION=us-west-2
- secure: "AbBK9m/ERyL2RzTd2+IwYkPxW+gnQSXB83AlcvgRNfGF+Y+zaDDZ4PaKDdl0hfKmsIwzvxpTn/t3pwN/UXYCdcKVzQFHmqhpgL1Vb6D6GV0tzSE87L9jod+5H5zFo4MufxIV2WpiV2yErJh+pl24l3kBuoJc7Ot3D3gj3tjLSCU="
- secure: "dfwJP2lOpCJxQ23ZiLOlDvuCvpwQOATE+U3Xgwwor7gqyoCMxqEdtSlVyt3PLx+LV1kWasJWuJ6pmrPplhk6CYXk/bQP9DNIJgnKiJdorg1/sxz/w2/KtuzizT+Kru+ZJVVgBcD8T1dTNFnFsPYtTrS/UdFyJ1M7gD+U7+QpuhI="

before_install:
- gem install rake -v "10.5.0"
- gem install fpm -v "1.8.1"
- sudo apt-get install -y rpm
# Workaround for https://github.com/travis-ci/travis-ci/issues/6126
- export GOOS=$TRAVIS_GOOS
- export GOARCH=$TRAVIS_GOARCH
# RPM signing
- pip install --user awscli
- export PATH=$PATH:$HOME/.local/bin
- ./build/setup-gpg
script:
- "./build/travis.sh"
deploy:
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
### 1.1.3-2 (2018-02-15)
#### Bug Fixes
- Fix syntax error in RPM post script -
[Issue #760](https://github.com/sensu/uchiwa/issues/760)

### 1.1.3 (2018-01-30)
#### Bug Fixes
- Fix typo in TLS cipher list -
[PR #759](https://github.com/sensu/uchiwa/pull/759)

### 1.1.2 (2018-01-26)
#### Bug Fixes
- Validate both check & client subscriptions when determing if a check is
silenced - [Issue #755](https://github.com/sensu/uchiwa/issues/755)
- Fix logrotate configuration file permission -
[Issue #757](https://github.com/sensu/uchiwa/issues/757)
- Fix Travis CI builds for both uchiwa & uchiwa-web projects
- Upgrade `istanbul` & `grunt-contrib-watch` dependencies

### 1.1.1 (2018-01-10)
#### Bug Fixes
- Fix the display of Uchiwa configuration in info view -
[PR #753](https://github.com/sensu/uchiwa/pull/753)
- Fix the Uchiwa logo in Firefox -
[Issue #749](https://github.com/sensu/uchiwa/issues/749)

#### Other
- Allow custom build of packages with Docker -
[PR #718](https://github.com/sensu/uchiwa/pull/718)

### 1.1.0 (2017-12-15)
#### Features
- Removed 3DES cipher algorithms from default suite -
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uchiwa",
"dependencies": {
"uchiwa-web": "1.1.0"
"uchiwa-web": "1.1.3"
}
}
22 changes: 22 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.8.1-alpine

ENV GOARCH=amd64

# Disable cgo so that binaries we build will be fully static.
ENV CGO_ENABLED=0

RUN apk add --no-cache \
bash \
build-base \
git \
libffi-dev \
make \
nodejs \
rpm \
ruby-dev \
ruby-rake \
tar && \
gem install rake -v "10.5.0" --no-ri --no-rdoc && \
gem install fpm -v "1.8.1" --no-ri --no-rdoc && \
rm -rf /usr/lib/ruby/gems/*/cache/* && \
rm -rf ~/.gem
5 changes: 5 additions & 0 deletions build/pkg_scripts/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ create_uchiwa_user_group() {
fi
}

fix_logrotate_permissions() {
chmod 644 /etc/logrotate.d/uchiwa
}

case "$1" in
configure)
create_uchiwa_user_group
fix_logrotate_permissions
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand Down
1 change: 1 addition & 0 deletions build/pkg_scripts/rpm/post
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
if [ $1 -eq 1 ]; then
chkconfig --add uchiwa
chkconfig uchiwa off
chmod 644 /etc/logrotate.d/uchiwa
fi
6 changes: 4 additions & 2 deletions build/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ echo "" > coverage.txt

for d in $(go list ./... | grep -v vendor); do
race=""
if [ $GOARCH == "amd64" ]; then
# The race detector is broken on Alpine. That is #14481 (and #9918).
# So disable it for now.
if [ "${GOARCH}" = "amd64" ] && [ ! -f /etc/alpine-release ]; then
race="-race"
fi

go test $race -coverprofile=profile.out -covermode=atomic $d
go test $race -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
Expand Down
5 changes: 5 additions & 0 deletions build/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if [ "$(git describe --tags --exact-match "$COMMIT")" ]; then
echo "======================== Running tests"
GOARCH=$GOARCH ./build/tests.sh

echo "======================== Prepare RPM signing"
pip install --user awscli
export PATH=$PATH:$HOME/.local/bin
./build/setup-gpg

echo "======================== Building the packages"
PACKAGE_VERSION=$PACKAGE_VERSION BUILD_NUMBER=$BUILD_NUMBER \
GOOS=$GOOS GOARCH=$GOARCH \
Expand Down
62 changes: 31 additions & 31 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
<title ng-bind="titleFactory.get()">uchiwa</title>

<!-- Customized Bootstrap -->
<link href="bower_components/uchiwa-web/css/bootstrap-uchiwa/bootstrap-uchiwa.css?rel=1513368934327" rel="stylesheet">
<link href="bower_components/uchiwa-web/css/bootstrap-uchiwa/bootstrap-uchiwa.css?rel=1518712994284" rel="stylesheet">

<!-- 3rd Party CSS -->
<link href="bower_components/fontawesome/css/font-awesome.min.css?rel=1513368934327" rel="stylesheet">
<link href="bower_components/angular-toastr/dist/angular-toastr.min.css?rel=1513368934327" rel="stylesheet">
<link href="bower_components/highlightjs/styles/tomorrow.css?rel=1513368934327" rel="stylesheet">
<link href="bower_components/moment-picker/dist/angular-moment-picker.min.css?rel=1513368934327" rel="stylesheet">
<link href="bower_components/jsoneditor/dist/jsoneditor.min.css?rel=1513368934327" rel="stylesheet">
<link href="bower_components/fontawesome/css/font-awesome.min.css?rel=1518712994284" rel="stylesheet">
<link href="bower_components/angular-toastr/dist/angular-toastr.min.css?rel=1518712994284" rel="stylesheet">
<link href="bower_components/highlightjs/styles/tomorrow.css?rel=1518712994284" rel="stylesheet">
<link href="bower_components/moment-picker/dist/angular-moment-picker.min.css?rel=1518712994284" rel="stylesheet">
<link href="bower_components/jsoneditor/dist/jsoneditor.min.css?rel=1518712994284" rel="stylesheet">

<!-- Uchiwa CSS -->
<link href="bower_components/uchiwa-web/css/uchiwa-default/uchiwa-default.css?rel=1513368934327" rel="stylesheet" site-theme>
<link href="bower_components/uchiwa-web/css/uchiwa-default/uchiwa-default.css?rel=1518712994284" rel="stylesheet" site-theme>
</head>

<body>
Expand All @@ -40,31 +40,31 @@ <h3 class="font-bold">We couldn't load Uchiwa configuration.</h3>
<ng-view></ng-view>

<!-- 3rd Party JS -->
<script src="bower_components/angular/angular.min.js?rel=1513368934325"></script>
<script src="bower_components/angular-cookies/angular-cookies.min.js?rel=1513368934326"></script>
<script src="bower_components/angular-resource/angular-resource.min.js?rel=1513368934326"></script>
<script src="bower_components/angular-route/angular-route.min.js?rel=1513368934326"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.min.js?rel=1513368934326"></script>
<script src="bower_components/angular-toastr/dist/angular-toastr.tpls.min.js?rel=1513368934326"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js?rel=1513368934326"></script>
<script src="bower_components/highlightjs/highlight.pack.js?rel=1513368934326"></script>
<script src="bower_components/moment/min/moment.min.js?rel=1513368934326"></script>
<script src="bower_components/angular-moment/angular-moment.min.js?rel=1513368934326"></script>
<script src="bower_components/moment-picker/dist/angular-moment-picker.min.js?rel=1513368934326"></script>
<script src="bower_components/angular-gravatar/build/angular-gravatar.min.js?rel=1513368934326"></script>
<script src="bower_components/jsoneditor/dist/jsoneditor.min.js?rel=1513368934326"></script>
<script src="bower_components/ng-jsoneditor/ng-jsoneditor.js?rel=1513368934327"></script>
<script src="bower_components/ua-parser-js/dist/ua-parser.min.js?rel=1513368934327"></script>
<script src="bower_components/angular/angular.min.js?rel=1518712994282"></script>
<script src="bower_components/angular-cookies/angular-cookies.min.js?rel=1518712994282"></script>
<script src="bower_components/angular-resource/angular-resource.min.js?rel=1518712994282"></script>
<script src="bower_components/angular-route/angular-route.min.js?rel=1518712994283"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.min.js?rel=1518712994283"></script>
<script src="bower_components/angular-toastr/dist/angular-toastr.tpls.min.js?rel=1518712994283"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js?rel=1518712994283"></script>
<script src="bower_components/highlightjs/highlight.pack.js?rel=1518712994283"></script>
<script src="bower_components/moment/min/moment.min.js?rel=1518712994283"></script>
<script src="bower_components/angular-moment/angular-moment.min.js?rel=1518712994283"></script>
<script src="bower_components/moment-picker/dist/angular-moment-picker.min.js?rel=1518712994283"></script>
<script src="bower_components/angular-gravatar/build/angular-gravatar.min.js?rel=1518712994283"></script>
<script src="bower_components/jsoneditor/dist/jsoneditor.min.js?rel=1518712994283"></script>
<script src="bower_components/ng-jsoneditor/ng-jsoneditor.js?rel=1518712994284"></script>
<script src="bower_components/ua-parser-js/dist/ua-parser.min.js?rel=1518712994284"></script>

<!-- Uchiwa JS -->
<script src="bower_components/uchiwa-web/js/bootstrap.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/app.js?rel=1513368934324"></script>
<script src="bower_components/uchiwa-web/js/common.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/constants.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/controllers.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/directives.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/factories.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/filters.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/services.js?rel=1513368934325"></script>
<script src="bower_components/uchiwa-web/js/bootstrap.js?rel=1518712994281"></script>
<script src="bower_components/uchiwa-web/js/app.js?rel=1518712994281"></script>
<script src="bower_components/uchiwa-web/js/common.js?rel=1518712994281"></script>
<script src="bower_components/uchiwa-web/js/constants.js?rel=1518712994281"></script>
<script src="bower_components/uchiwa-web/js/controllers.js?rel=1518712994282"></script>
<script src="bower_components/uchiwa-web/js/directives.js?rel=1518712994282"></script>
<script src="bower_components/uchiwa-web/js/factories.js?rel=1518712994282"></script>
<script src="bower_components/uchiwa-web/js/filters.js?rel=1518712994282"></script>
<script src="bower_components/uchiwa-web/js/services.js?rel=1518712994282"></script>
</body>
</html>
16 changes: 11 additions & 5 deletions uchiwa/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"github.com/sensu/uchiwa/uchiwa/logger"
)

func (u *Uchiwa) buildClientHistory(client, dc string, history []interface{}) []interface{} {
func (u *Uchiwa) buildClientHistory(client map[string]interface{}, dc string, history []interface{}) []interface{} {
for _, h := range history {
m, ok := h.(map[string]interface{})
if !ok {
logger.Warningf("Could not assert this client history to an interface: %+v", h)
continue
}

m["client"] = client
m["client"] = client["name"].(string)
m["dc"] = dc

checkMap, ok := m["last_result"].(map[string]interface{})
Expand All @@ -24,8 +24,7 @@ func (u *Uchiwa) buildClientHistory(client, dc string, history []interface{}) []
continue
}

clientMap := map[string]interface{}{"name": client}
m["silenced"], m["silenced_by"] = helpers.IsCheckSilenced(checkMap, clientMap, dc, u.Data.Silenced)
m["silenced"], m["silenced_by"] = helpers.IsCheckSilenced(checkMap, client, dc, u.Data.Silenced)
}

return history
Expand Down Expand Up @@ -107,11 +106,18 @@ func (u *Uchiwa) GetClientHistory(dc, name string) ([]interface{}, error) {
return nil, err
}

// Get the client
client, err := u.GetClient(dc, name)
if err != nil {
// The error would already have been logged at this point
return nil, err
}

// lock results
u.Mu.Lock()
defer u.Mu.Unlock()

history := u.buildClientHistory(name, dc, h)
history := u.buildClientHistory(client, dc, h)

return history, nil
}
Expand Down
5 changes: 2 additions & 3 deletions uchiwa/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestBuildClientHistory(t *testing.T) {
var client, dc string
var dc string
var status float64
const Critical float64 = 2.0
const Warning float64 = 1.0
Expand All @@ -25,14 +25,13 @@ func TestBuildClientHistory(t *testing.T) {
map[string]interface{}{"check": "cpu", "client": "qux", "dc": "us-west-1", "occurrences": 10, "output": "CRITICAL", "status": Critical},
}

client = "qux"
client := map[string]interface{}{"name": "qux"}
dc = "us-east-1"
status = Success
history = []interface{}{map[string]interface{}{"check": "cpu", "last_result": map[string]interface{}{"command": "cpu.rb", "status": status}, "last_status": status}}
expectedHistory = []interface{}{map[string]interface{}{"check": "cpu", "client": "qux", "dc": "us-east-1", "last_result": map[string]interface{}{"command": "cpu.rb", "status": status}, "last_status": status, "silenced": false, "silenced_by": []string(nil)}}
result := u.buildClientHistory(client, dc, history)
assert.Equal(t, expectedHistory, result)

}

func TestFindClient(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions uchiwa/config/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type LdapServer struct {
GroupMemberAttribute string
Insecure bool
Security string
TLSConfig *tls.Config
TLSConfig *tls.Config `json:"-"`
UserAttribute string
UserBaseDN string
UserObjectClass string
Expand All @@ -131,7 +131,7 @@ type SSL struct {
KeyFile string
CipherSuite []string
TLSMinVersion string
TLSConfig *tls.Config
TLSConfig *tls.Config `json:"-"`
}

// UsersOptions struct contains various config tweaks
Expand Down
2 changes: 1 addition & 1 deletion uchiwa/config/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func parseCipherSuite(ids []string) []uint16 {
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256": tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
"TvLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305": tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305": tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
Expand Down
26 changes: 17 additions & 9 deletions uchiwa/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ func InterfaceToString(i []interface{}) []string {
// Returns true if the check is silenced and a slice of silence entries IDs
func IsCheckSilenced(check, client map[string]interface{}, dc string, silenced []interface{}) (bool, []string) {
var isSilenced bool
var isSilencedBy []string
var subscribers []interface{}
var commonSubscriptions, isSilencedBy, subscribers, subscriptions []string

if dc == "" || len(silenced) == 0 {
return false, isSilencedBy
Expand All @@ -264,18 +263,28 @@ func IsCheckSilenced(check, client map[string]interface{}, dc string, silenced [
clientName = ""
}

// Retrieve the check subscribers
if check["subscribers"] != nil {
subscribers, ok = check["subscribers"].([]interface{})
s, ok := check["subscribers"].([]interface{})
if !ok {
return false, isSilencedBy
}
subscribers = InterfaceToString(s)
}

// Retrieve the client subscriptions
if client["subscriptions"] != nil {
subscriptions, ok := client["subscriptions"].([]interface{})
if ok {
// Add the client subscriptions to the subscribers slice
subscribers = append(subscribers, subscriptions...)
s, ok := client["subscriptions"].([]interface{})
if !ok {
return false, isSilencedBy
}
subscriptions = InterfaceToString(s)
}

// Get the subscriptions both check and client have in common
for _, subscriber := range subscribers {
if IsStringInArray(subscriber, subscriptions) {
commonSubscriptions = append(commonSubscriptions, subscriber)
}
}

Expand Down Expand Up @@ -311,8 +320,7 @@ func IsCheckSilenced(check, client map[string]interface{}, dc string, silenced [
continue
}

for _, s := range subscribers {
subscription := s.(string)
for _, subscription := range commonSubscriptions {
// Subscription (e.g. load-balancer:* )
if m["id"] == fmt.Sprintf("%s:*", subscription) {
isSilenced = true
Expand Down
Loading

0 comments on commit 091e808

Please sign in to comment.