Example #1
0
func New(next http.Handler) (*LanternProFilter, error) {
	return &LanternProFilter{
		next:           next,
		proTokens:      set.New(),
		clientRegistry: ctrie.New(nil),
	}, nil
}
	if config.EvaluateUnlistedResources {
		glog.Info("No resource listing matched, creating event.")
		go ids.AddEvent("Request", "RE1", r)
	}
}

var config VerbsConfig

type VerbsConfig struct {
	EnableGlobalPreflightRequests bool
	EvaluateUnlistedResources     bool
	Resources                     map[string][]string
}

var staticResourcePaths = set.New()
var regexResourcePaths = make([]*regexp.Regexp, 0)

func PopulateExpectedVerbs(verbsYamlFile *string) {
	//var config VerbsConfig

	source, err := ioutil.ReadFile(*verbsYamlFile)
	if err != nil {
		panic(err)
	}

	err = yaml.Unmarshal(source, &config)
	if err != nil {
		panic(err)
	}
	}

	for _, re := range regexPaths {
		if re.MatchString(r.URL.Path) {
			// found match with regex, we're good
			return
		}
	}

	//create event - didn't find a match
	glog.Info("Did not find matching resource - creating event.")
	go ids.AddEvent("Access Control", "ACE1", r)

}

var staticPaths = set.New()
var regexPaths = make([]*regexp.Regexp, 0)

//var expectedResources = set.New()

type ResourcesConfig struct {
	Resources []string
}

func PopulateExpectedResources(resourcesYamlFile *string) {
	var config ResourcesConfig

	source, err := ioutil.ReadFile(*resourcesYamlFile)
	if err != nil {
		panic(err)
	}
	// both have values
	if ip != "" && res != "" {
		//fmt.Println("both")
		return ip == b.Ipaddress && res == b.Resource
	}

	// only ip has value
	if ip != "" {
		//fmt.Println("ip only")
		return ip == b.Ipaddress
	}

	// only res has value
	if res != "" {
		//fmt.Println("res only")
		return res == b.Resource
	}

	return false
}

type Blocks []Block

var StoredBlocks = set.New()

func unixToTime(s int64) (time.Time, error) {
	//return time.Unix(0, ms*int64(time.Millisecond)), nil
	return time.Unix(s, 0), nil
}