Strip sensitive information (passwords, credit card numbers, cvv2 codes) from requests/responses.

@access protected

@param mixed $log  The log to sanitize.
@return string  The sanitized (and string-ified, if necessary) log.
770245
function _sanitizeLog($log, $allsensitive = false) {
    if (is_array($log)) {
      foreach (array_keys($log) as $key) {
        switch (strtolower($key)) {
          case 'pwd':
          case 'cvv2':
            $log[$key] = str_repeat('*', strlen($log[$key]));
            break;

          case 'signature':
          case 'acct':
            $log[$key] = str_repeat('*', strlen(substr($log[$key], 0, -4))) . substr($log[$key], -4);
            break;
          case 'solutiontype':
            unset($log[$key]);
            break;
        }
        if ($allsensitive && in_array($key, array('BUTTONSOURCE', 'VERSION', 'SIGNATURE', 'USER', 'VENDOR', 'PARTNER', 'PWD', 'VERBOSITY'))) unset($log[$key]);
      }
      return print_r($log, true);
    } else {
      return $log;
    }
  }
578950
def delete_log(self, log):
        ''''''
        if os.path.splitext(log)[-1] != '.log':
            raise Exception('File without .log was passed in for deletoin')
        with suppress(Exception):
            os.remove(log)
758719
public function specEnd($log = null)
    {
        switch ($log->type()) {
            case 'passed':
                $this->_write($this->_symbols['dot']);
                break;
            case 'skipped':
                $this->_write('S', 'light-grey');
                break;
            case 'pending':
                $this->_write('P', 'cyan');
                break;
            case 'excluded':
                $this->_write('X', 'yellow');
                break;
            case 'failed':
                $this->_write('F', 'red');
                break;
            case 'errored':
                $this->_write('E', 'magenta');
                break;
        }
    }
503287
public function col_timesplitting($log) {
        $timesplitting = \core_analytics\manager::get_time_splitting($log->timesplitting);
        return $timesplitting->get_name();
    }
1368087
public function cleanParamsForLog($data)
    {
        foreach ($data as $key => &$value) {
            if (in_array($key, $this->obfuscationFields)) {
                $value = self::OBFUSCATION_STRING;
            }

            if (in_array($key, $this->removeFields)) {
                $value = self::REMOVED_STRING;
            }
        }

        return $data;
    }
1217307
public function sanitize($value)
    {
        $value = trim($value);

        $parts  = explode('-', $value, 2);
        if(2 != count($parts)) {
            return null;
        }

        $parts[0]   = substr(preg_replace('/[^a-z]*/', '', $parts[0]), 0, 2);
        $parts[1]   = substr(preg_replace('/[^A-Z]*/', '', $parts[1]), 0, 2);
        $result = implode('-', $parts);

        // just making sure :-)
        if($this->validate($result)) {
            return $result;
        }

        return null;
    }
470671
private function isEndOfLog($log)
    {
        $is_end = preg_match('/\nTime: \d+ s./', $log);

        // end of execute scan on Windows
        $root = realpath($this->getParameter('kernel.root_dir').'/../');
        $is_end_win = preg_match('/\n'.preg_quote($root).'>/', $log);

        // detect fatal error in log
        $is_end_error = strpos($log, 'Fatal error: ') != false;

        return $is_end || $is_end_win || $is_end_error;
    }
565472
protected function log($log){
        if (is_array($log)) $log = print_r($log,true);
        if ($this->debug) {
            if (function_exists($this->logcallback)) {
                return call_user_func($this->logcallback,$log);
            }elseif ($this->logfile) {
                return file_put_contents($this->logfile, $log."\n", FILE_APPEND) > 0 ? true : false;
            }
        }
        return false;
    }
623748
private function sanitize($filename)
    {
        $filename = preg_replace('/[^A-Za-z0-9\-\._]/', '.', (string) $filename);
        return trim(substr(preg_replace('/[_\.\-]{2,}/', '.', $filename), 0, 40), '._-');
    }
710644
function _stripDelimiter($entry)
    {
        $beginningdels = array_keys($this->_delimiters);
        $length = strlen($entry);
        $firstchar = substr($entry, 0, 1);
        $lastchar = substr($entry, -1, 1);
        while (in_array($firstchar, $beginningdels)) { //The first character is an opening delimiter
            if ($lastchar == $this->_delimiters[$firstchar]) { //Matches to closing Delimiter
                $entry = substr($entry, 1, -1);
            } else {
                break;
            }
            $firstchar = substr($entry, 0, 1);
            $lastchar = substr($entry, -1, 1);
        }
        return $entry;
    }
1075684
public static function strip($buffer) {
		$pat = ["=^\s+=", "=\s{2,}=", "=\s+\$=", "=>\s*<([a-z])="];
		$rep = ["", " ", "", "><$1"];
		$buffer = preg_replace($pat, $rep, $buffer);
		return $buffer;
	}
1143124
public function parseLog($log)
    {
        $commits = $tags = [];

        for ($i = 0, $lines = count($log); $i < $lines; $i++) {
            $tmp = explode(': ', $log[$i]);
            $tmp = array_map('trim', $tmp);

            if ($tmp[0] == 'changeset') {
                $commit = $tmp[1];
            }

            if ($tmp[0] == 'user') {
                $email  = $this->extractEmail($tmp[1]);
                $author = $this->extractAuthor($tmp[1]);
            }

            if ($tmp[0] == 'date') {
                $date = trim($tmp[1]);
            }

            if ($tmp[0] == 'tag') {
                $tags[] = trim($tmp[1]);
            }

            if ($tmp[0] == 'summary') {
                $commits[] = [
                    'commit'  => trim($commit),
                    'author'  => trim($author),
                    'email'   => trim($email),
                    'date'    => DateTime::createFromFormat('D M j H:i:s Y O', $date),
                    'summary' => trim($tmp[1]),
                    'tags'    => $tags,
                    'vcs'     => trim($this->repository_type),
                ];
                $tags = [];
            }
        }

        return $commits;
    }
825424
protected function stripPrefix(string $table): string {
        $len = strlen($this->px);
        if (strcasecmp(substr($table, 0, $len), $this->px) === 0) {
            $table = substr($table, $len);
        }
        return $table;
    }
652081
public function stripSpecialCharacter($content)
    {
        if (is_string($content))
        {
            $content = str_replace(chr(194) . chr(160), ' ', $content);
        }

        return $content;
    }
557910
public function col_info($log) {
        global $PAGE;

        if (empty($log->info) && empty($log->dir)) {
            return '';
        }

        $info = array();
        if (!empty($log->info)) {
            $info = json_decode($log->info);
        }
        if (!empty($log->dir)) {
            $info[] = get_string('predictorresultsin', 'tool_analytics', $log->dir);
        }
        $PAGE->requires->js_call_amd('tool_analytics/log_info', 'loadInfo', array($log->id, $info));
        return \html_writer::link('#', get_string('view'), array('data-model-log-id' => $log->id));
    }
138575
public static function log( $log ) {
	
		if ( ! self::is_debug() ) {
			return;
		}

		if ( is_bool( $log ) ) {
			$log = $log ? 'true' : 'false';
		}

		/**
		 * __FILE__
		 * __LINE__
		 * https://stackoverflow.com/questions/1252529/get-code-line-and-file-thats-executing-the-current-function-in-php
		 */
		$bt = debug_backtrace();
		$caller = array_shift( $bt );

		error_log( print_r( $caller['file'] . ' Line: ' . $caller['line'], true ) );
		error_log( print_r( $log, true ) );

		// if ( is_array( $log ) || is_object( $log ) ) {
		//  error_log( print_r( $log, true ) );
		// } else {
		//  error_log( $log );
		// }

	}
863708
public function formatLog($log, $test)
    {
        return !empty($log)
            ? $this->linkFiles($this->ansi2Html($log), $test)
            : $log;
    }