masker

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

README

sql-mask Build Status

sql-mask is a tool to mask literal in SQL queries. sql-mask support MySQL and PostgreSQL.

Installation

go get -u github.com/Komei22/sql-mask

Usage

Masking MySQL query
package main

import (
	"fmt"
	"github.com/Komei22/sql-mask"
)

func main() {
	query := "SELECT * FROM `user` WHERE `id` = 1"

	m := &masker.MysqlMasker{}
	queryDigest, err := masker.Mask(m, query)
	if err != nil {
		panic(err)
	}

	fmt.Println(queryDigest)
}

Running will output the query digest which is masked the literal value of input MySQL query:

$ go run main.go
SELECT * FROM `user` WHERE `id` = ?
Masking PostgreSQL query
package main

import (
	"fmt"
	"github.com/Komei22/sql-mask"
)

func main() {
	query := `SELECT * FROM "user" WHERE "id" = 1`

	m := &masker.PgMasker{}
	queryDigest, err := masker.Mask(m, query)
	if err != nil {
		panic(err)
	}

	fmt.Println(queryDigest)
}

Running will output the query digest which is masked the literal value of input PostgreSQL query:

$ go run main.go
SELECT * FROM "user" WHERE "id" = ?

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mask

func Mask(m Masker, query string) (string, error)

Mask mask literal values in a query

Types

type Masker

type Masker interface {
	// contains filtered or unexported methods
}

Masker is masker interface

type MysqlMasker

type MysqlMasker struct{}

MysqlMasker is masker for mysql

type PgMasker

type PgMasker struct{}

PgMasker is masker for PostgreSQL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL