Skip to content

Commit

Permalink
Merge pull request #5 from Ma3oBblu/travis
Browse files Browse the repository at this point in the history
add travis config, readme, license
  • Loading branch information
Ma3oBblu committed May 5, 2021
2 parents 9fe5315 + a7e25e1 commit 3f02bc2
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
/vendor
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: go
go:
- "1.16"

env:
- env GO111MODULE=on

script:
- go mod vendor
- go test -v -race -coverprofile=coverage.txt -covermode=atomic

after_success:
- bash <(curl -s https://codecov.io/bash)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 White Chang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module masker

go 1.16
4 changes: 2 additions & 2 deletions masker.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (m *Masker) Mobile(i string) string {
return m.mask(i, "*****", 4, 9)
}

// Password максирует пароль заданной маской
// Password маскирует пароль заданной маской
func (m *Masker) Password(i string) string {
l := len([]rune(i))
if l == 0 {
Expand Down Expand Up @@ -154,7 +154,7 @@ func (m *Masker) PassportNumber(i string) string {

// Code маскирует код из цифр
// для кодов состоящих из меньше чем 4 символов, оставляет первый символ
// для кодо большей длины оставляет первый и последний символ
// для кодов большей длины оставляет первый и последний символ
func (m *Masker) Code(i string) string {
if len(i) == 0 {
return ""
Expand Down
66 changes: 65 additions & 1 deletion readme.MD
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
# masker for sensitive information
# Masker

[![Build Status](https://travis-ci.org/ma3obblu/masker.svg?branch=master)](https://travis-ci.org/ma3obblu/masker)
[![codecov](https://codecov.io/gh/ma3obblu/masker/branch/master/graph/badge.svg)](https://codecov.io/gh/ma3obblu/masker)
[![Go Report Card](https://goreportcard.com/badge/github.com/ma3obblu/masker)](https://goreportcard.com/report/github.com/ma3obblu/masker)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/ma3obblu/masker/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/ma3obblu/masker?status.svg)](https://godoc.org/github.com/ma3obblu/masker)
[![Release](https://img.shields.io/github/release/ma3obblu/masker.svg?style=flat-square)](https://github.com/ma3obblu/masker/releases/latest)

Masker простая утилита для маскировки чувствительных данных.

# Установка

```
$ go get -u github.com/ma3obblu/masker
```

# Примеры

Два способа работы с masker:

#### 1. Получить инстанс напрямую из пакета masker

``` golang
package main

import (
masker "github.com/ma3obblu/masker"
)

func main() {
masker.Name("Руслан")
masker.Mobile("79191232323")
}
```

#### 2. Получить инстанс используя конструктор `masker.New()`

``` golang
package main

import (
masker "github.com/ma3obblu/masker"
)

func main() {
m := masker.New()
m.Name("Руслан")
m.Mobile("79191232323")
}
```

## Типы полей

|Type |Description |
|:----------:|:------------------------------------------------------------------------------------------------------|
|Name|маскирует второй и третий символ в строке. Может работать со строками из нескольких слов| |
|CreditCard|маскирует 6 символов номера кредитной карты начиная с 7|
|Email|маскирует логин в email, оставляя домен|
|Mobile|маскирует 11 значный номер телефона с ведущей цифрой 7, оставляет первые 4 и последние 2 цифры|
|Password|всегда вернет "************"|
|PassportSeries|маскирует серию паспорта, оставляя первую и последнюю цифры|
|PassportNumber|маскирует номер паспорта, оставляя первую и последнюю цифру|
|Code|маскирует код из цифр. Для кодов состоящих из меньше чем 4 символов, оставляет первый символ. Для кодов большей длины оставляет первый и последний символ|
|LastFourDigits|маскирует любую последовательность больше 5 символов, оставляя 4 последних символа|

0 comments on commit 3f02bc2

Please sign in to comment.