Skip to content

Commit

Permalink
Move antiCheat export to proper exports
Browse files Browse the repository at this point in the history
  • Loading branch information
J12934 committed May 6, 2023
1 parent edd9c99 commit c955911
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/antiCheat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import config = require('config')
import colors from 'colors/safe'
import { retrieveCodeSnippet } from '../routes/vulnCodeSnippet'
import { readFixes } from '../routes/vulnCodeFixes'
import { Challenge } from '../data/types'
import { getCodeChallenges } from './codingChallenges'
import logger from './logger'
import colors from 'colors/safe'

const coupledChallenges = { // TODO prevent also near-identical challenges (e.g. all null byte file access or dom xss + bonus payload etc.) from counting as cheating
loginAdminChallenge: ['weakPasswordChallenge'],
Expand All @@ -22,7 +22,7 @@ const trivialChallenges = ['errorHandlingChallenge', 'privacyPolicyChallenge']

const solves: Array<{challenge: any, phase: string, timestamp: Date, cheatScore: number}> = [{ challenge: {}, phase: 'server start', timestamp: new Date(), cheatScore: 0 }] // seed with server start timestamp

exports.calculateCheatScore = (challenge: Challenge) => {
export const calculateCheatScore = (challenge: Challenge) => {
const timestamp = new Date()
let cheatScore = 0
let timeFactor = 2
Expand All @@ -41,7 +41,7 @@ exports.calculateCheatScore = (challenge: Challenge) => {
return cheatScore
}

exports.calculateFindItCheatScore = async (challenge: Challenge) => {
export const calculateFindItCheatScore = async (challenge: Challenge) => {
const timestamp = new Date()
let timeFactor = 0.001
timeFactor *= (challenge.key === 'scoreBoardChallenge' && config.get('hackingInstructor.isEnabled') ? 0.5 : 1)
Expand All @@ -67,7 +67,7 @@ exports.calculateFindItCheatScore = async (challenge: Challenge) => {
return cheatScore
}

exports.calculateFixItCheatScore = async (challenge: Challenge) => {
export const calculateFixItCheatScore = async (challenge: Challenge) => {
const timestamp = new Date()
let cheatScore = 0

Expand All @@ -81,7 +81,7 @@ exports.calculateFixItCheatScore = async (challenge: Challenge) => {
return cheatScore
}

exports.totalCheatScore = () => {
export const totalCheatScore = () => {
return solves.length > 1 ? solves.map(({ cheatScore }) => cheatScore).reduce((sum, score) => { return sum + score }) / (solves.length - 1) : 0
}

Expand Down

0 comments on commit c955911

Please sign in to comment.