<commit_before>package etd

import (
	"encoding/json"
	"regexp"
	"strings"

	"github.com/googlecloudplatform/threat-automation/entities"

	"cloud.google.com/go/pubsub"
	"github.com/pkg/errors"
)

// Copyright 2019 Google LLC
//
// 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
//
// 	https://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.

const (
	// FindingSuffix is the log name suffix used by Event Threat Detection's findings.
	FindingSuffix = "/logs/threatdetection.googleapis.com%2Fdetection"
)

var (
	// extractProject used to extract a project Number from an affected resource.
	extractProject = regexp.MustCompile(`/projects/(.*)$`)
	// extractResource used to extract a resource.
	extractResource = regexp.MustCompile(`/([^/]+?/[^/]+?)?$`)
	// extractInstance used to extract a instance.
	extractInstance = regexp.MustCompile(`/instances/(.*)$`)
)

// baseFinding contains fields all ETD findings should provide.
type baseFinding struct {
	JSONPayload struct {
		AffectedResources []struct {
			GCPResourceName string
		}
		DetectionCategory struct {
			SubRuleName string
			RuleName    string
		}
		Properties struct {
			ProjectID string
		}
	}
}

// Finding is a 'base' struct representing ETD fields that all findings should satisfy.
type Finding struct {
	base *baseFinding
}

// NewFinding deserializes a basic ETD finding from StackDriver.
func NewFinding(m *pubsub.Message) (*Finding, error) {
	var sd entities.StackDriverLog
	f := &Finding{}<commit_msg>add back in required json tag<commit_after>package etd

import (
	"encoding/json"
	"regexp"
	"strings"

	"github.com/googlecloudplatform/threat-automation/entities"

	"cloud.google.com/go/pubsub"
	"github.com/pkg/errors"
)

// Copyright 2019 Google LLC
//
// 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
//
// 	https://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.

const (
	// FindingSuffix is the log name suffix used by Event Threat Detection's findings.
	FindingSuffix = "/logs/threatdetection.googleapis.com%2Fdetection"
)

var (
	// extractProject used to extract a project Number from an affected resource.
	extractProject = regexp.MustCompile(`/projects/(.*)$`)
	// extractResource used to extract a resource.
	extractResource = regexp.MustCompile(`/([^/]+?/[^/]+?)?$`)
	// extractInstance used to extract a instance.
	extractInstance = regexp.MustCompile(`/instances/(.*)$`)
)

// baseFinding contains fields all ETD findings should provide.
type baseFinding struct {
	JSONPayload struct {
		AffectedResources []struct {
			GCPResourceName string
		}
		DetectionCategory struct {
			SubRuleName string
			RuleName    string
		}
		Properties struct {
			ProjectID string `json:"project_id"`
		}
	}
}

// Finding is a 'base' struct representing ETD fields that all findings should satisfy.
type Finding struct {
	base *baseFinding
}

// NewFinding deserializes a basic ETD finding from StackDriver.
func NewFinding(m *pubsub.Message) (*Finding, error) {
	var sd entities.StackDriverLog
	f := &Finding{}
{'fraction_non_alphanumeric': 0.10258397932816538, 'fraction_numerical': 0.004651162790697674, 'mean_word_length': 3.9312101910828026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1174349', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1080, 'n_words': 403}