<commit_before><!--
 Copyright 2021 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

      http://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.
-->

<template>
  <div>
    <h1>{{ this.$route.params.vulnId }}</h1>
    <b-alert v-if="invalid" show variant="warning">
      This entry is invalid due to reproduction flake.
    </b-alert>
    <b-table-simple>
      <b-tr>
        <b-td>Package</b-td>
        <b-td>
          <a :href="getPackageLink(package_value)">{{ formatPackage(package_value) }}</a>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>Repo URL</b-td>
        <b-td>
        <a :href="repo_url">{{ repo_url }}</a>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>Summary</b-td>
        <b-td> {{ summary }}</b-td>
      </b-tr>
      <b-tr>
        <b-td>Details</b-td>
        <b-td><pre>{{ details }}</pre></b-td>
      </b-tr>
      <b-tr>
        <b-td>Severity</b-td>
        <b-td>{{ severity }}</b-td>
      </b-tr>
      <b-tr>
        <b-td>Introduced in</b-td>
        <b-td>
          <div v-for="commit in introduced_in" :key="commit.id">
            <a v-if="commit.link" :href="commit.link">
              <span v-html="formatCommit(commit)"></span>
            </a>
            <span v-else v-html="formatCommit(commit)"></span>
          </div>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>Fixed in</b-td>
        <b-td v-if="fixed_in">
          <div v-for="commit in fixed_in" :key="commit.id">
            <a v-if="commit.link" :href="commit.link">
              <span v-html="formatCommit(commit)"></span>
            </a>
            <span v-else v-html="formatCommit(commit)"></span>
          </div>
        </b-td>
        <b-td v-else><strong>Not fixed</strong></b-td>
      </b-tr>
      <b-tr>
        <b-td>Affected versions</b-td>
        <b-td>
          <span v-for="version in affected" :key="version">
            {{version.tag}}
          </span>
          <span v-if="invalid">
            INVALID
          </span>
          <span v-else-if="affected.length == 0">
            No impacted versions.
          </span>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>References</b-td>
        <b-td>
          <div v-for="link in references" :key="link">
            <a :href="link">{{ link }}</a>
          </div>
        </b-td>
      </b-tr>
    </b-table-simple>
  </div>
</template>

<script>
import helpers from '../mixins/helpers'

export default {
  name: 'Vulnerability',
  mixins: [helpers],
  data() {
    return {
      package_value: {},
      repo_url: '',
      summary: '',
      details: '',
      severity: '',
      introduced_in: {},
      fixed_in: null,
      affected: [],
      references: [],
      invalid: false,
      requestId: 0,
    };
  },

  methods: {
    async makeRequest() {
      const curId = ++this.requestId;
      const response = await fetch(
          `/backend/vulnerability?id=${this.$route.params.vulnId}`,
          { credentials: 'include' });
      if (response.status != 200) {
        this.$router.replace({name: 'notfound'});
      }

      const results = await response.json();
      if (curId != this.requestId) {
        // A newer request superseded this one.
        return;
      }

      this.package_value = results.package;
      this.repo_url = results.repo_url;
      this.summary = results.summary;
      this.details = results.details;
      this.severity = results.severity;
      this.introduced_in = results.regressed;
      if (results.fixed) {
        this.fixed_in = results.fixed;
      } else {
        this.fixed_in = null
      }
      this.affected = results.affected;
      this.references = results.references;
      this.invalid = results.invalid;

      document.title = `OSV-${results.id}`;
    },

    formatCommit(commit) {
      if (!commit)
        return '';

      if (commit.type == 'exact') {
        return commit.commit;
      }

      return commit.from + '<br>..<br>' + commit.to;
    },
  },

  watch: {
    '$route': function() {
       this.makeRequest();
    },
  },

  async mounted() {
    await this.makeRequest();
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.search {
  max-width: 400px;
}
</style>
<commit_msg>Fix repeated OSV- prefix in UI title. (#93)<commit_after><!--
 Copyright 2021 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

      http://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.
-->

<template>
  <div>
    <h1>{{ this.$route.params.vulnId }}</h1>
    <b-alert v-if="invalid" show variant="warning">
      This entry is invalid due to reproduction flake.
    </b-alert>
    <b-table-simple>
      <b-tr>
        <b-td>Package</b-td>
        <b-td>
          <a :href="getPackageLink(package_value)">{{ formatPackage(package_value) }}</a>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>Repo URL</b-td>
        <b-td>
        <a :href="repo_url">{{ repo_url }}</a>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>Summary</b-td>
        <b-td> {{ summary }}</b-td>
      </b-tr>
      <b-tr>
        <b-td>Details</b-td>
        <b-td><pre>{{ details }}</pre></b-td>
      </b-tr>
      <b-tr>
        <b-td>Severity</b-td>
        <b-td>{{ severity }}</b-td>
      </b-tr>
      <b-tr>
        <b-td>Introduced in</b-td>
        <b-td>
          <div v-for="commit in introduced_in" :key="commit.id">
            <a v-if="commit.link" :href="commit.link">
              <span v-html="formatCommit(commit)"></span>
            </a>
            <span v-else v-html="formatCommit(commit)"></span>
          </div>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>Fixed in</b-td>
        <b-td v-if="fixed_in">
          <div v-for="commit in fixed_in" :key="commit.id">
            <a v-if="commit.link" :href="commit.link">
              <span v-html="formatCommit(commit)"></span>
            </a>
            <span v-else v-html="formatCommit(commit)"></span>
          </div>
        </b-td>
        <b-td v-else><strong>Not fixed</strong></b-td>
      </b-tr>
      <b-tr>
        <b-td>Affected versions</b-td>
        <b-td>
          <span v-for="version in affected" :key="version">
            {{version.tag}}
          </span>
          <span v-if="invalid">
            INVALID
          </span>
          <span v-else-if="affected.length == 0">
            No impacted versions.
          </span>
        </b-td>
      </b-tr>
      <b-tr>
        <b-td>References</b-td>
        <b-td>
          <div v-for="link in references" :key="link">
            <a :href="link">{{ link }}</a>
          </div>
        </b-td>
      </b-tr>
    </b-table-simple>
  </div>
</template>

<script>
import helpers from '../mixins/helpers'

export default {
  name: 'Vulnerability',
  mixins: [helpers],
  data() {
    return {
      package_value: {},
      repo_url: '',
      summary: '',
      details: '',
      severity: '',
      introduced_in: {},
      fixed_in: null,
      affected: [],
      references: [],
      invalid: false,
      requestId: 0,
    };
  },

  methods: {
    async makeRequest() {
      const curId = ++this.requestId;
      const response = await fetch(
          `/backend/vulnerability?id=${this.$route.params.vulnId}`,
          { credentials: 'include' });
      if (response.status != 200) {
        this.$router.replace({name: 'notfound'});
      }

      const results = await response.json();
      if (curId != this.requestId) {
        // A newer request superseded this one.
        return;
      }

      this.package_value = results.package;
      this.repo_url = results.repo_url;
      this.summary = results.summary;
      this.details = results.details;
      this.severity = results.severity;
      this.introduced_in = results.regressed;
      if (results.fixed) {
        this.fixed_in = results.fixed;
      } else {
        this.fixed_in = null
      }
      this.affected = results.affected;
      this.references = results.references;
      this.invalid = results.invalid;

      document.title = `${results.id}`;
    },

    formatCommit(commit) {
      if (!commit)
        return '';

      if (commit.type == 'exact') {
        return commit.commit;
      }

      return commit.from + '<br>..<br>' + commit.to;
    },
  },

  watch: {
    '$route': function() {
       this.makeRequest();
    },
  },

  async mounted() {
    await this.makeRequest();
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.search {
  max-width: 400px;
}
</style>

{'fraction_non_alphanumeric': 0.16670205988532596, 'fraction_numerical': 0.004034826927160756, 'mean_word_length': 1.8603097479501973, 'pattern_counts': {'":': 0, '<': 219, '<?xml version=': 0, '>': 219, 'https://': 0, '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': '2556420', 'n_tokens_mistral': 3183, 'n_tokens_neox': 3112, 'n_words': 709}