<commit_before>from .base_executor import ScriptExecutor
from judgeenv import env

class Executor(ScriptExecutor):
    ext = '.R'
    name = 'R'
    nproc = 100 # needs a bunch
    command = env['runtime'].get('Rscript')
    test_program = 'writeLines(readLines(file("stdin")))'
    syscalls = ['socketcall', 'mkdir', 'setup', 'fork', 'waitpid', 'getpgrp', 'dup2', 'nanosleep',
                'getppid', 'getpid', 'sched_getaffinity', 'execve']

    fs = ['stdin', '.*\.(?:so|rdb|rdx|rds|R)', '/lib/', '/etc/ld\.so\.(?:cache|preload|nohwcap)$', '/proc/stat$',
          '/usr/lib/', '/usr/local/lib/', '/etc/passwd$', '/proc/meminfo$', '/sys/devices/system/cpu/online$',
          '/etc/nsswitch.conf$', '/etc/group$', '/dev/(?:null|urandom|random|tty|stdin|stdout|stderr)$']

    def get_cmdline(self):
        return [self.get_command(), '--vanilla', self._code]

initialize = Executor.initialize

<commit_msg>Alleviate @Xyene's fear of socketcall #125<commit_after>import errno

from .base_executor import ScriptExecutor
from judgeenv import env
from cptbox.syscalls import *


class Executor(ScriptExecutor):
    ext = '.R'
    name = 'R'
    nproc = -1 # needs a bunch
    command = env['runtime'].get('Rscript')
    test_program = 'writeLines(readLines(file("stdin")))'
    syscalls = ['mkdir', 'setup', 'fork', 'waitpid', 'getpgrp', 'dup2', 'nanosleep',
                'getppid', 'getpid', 'sched_getaffinity', 'execve']

    fs = ['stdin', '.*\.(?:so|rdb|rdx|rds|R)', '/lib/', '/etc/ld\.so\.(?:cache|preload|nohwcap)$', '/proc/stat$',
          '/usr/lib/', '/usr/local/lib/', '/etc/passwd$', '/proc/meminfo$', '/sys/devices/system/cpu/online$',
          '/etc/nsswitch.conf$', '/etc/group$', '/dev/(?:null|urandom|random|tty|stdin|stdout|stderr)$']

    def get_security(self):
        security = super(Executor, self).get_security()

        def handle_socket(debugger):
            def socket_return():
                debugger.result = -errno.EACCES
            debugger.syscall = debugger.getpid_syscall
            debugger.on_return(socket_return)
            return True

        security[sys_socket] = handle_socket
        security[sys_socketcall] = handle_socket
        return security

    def get_cmdline(self):
        return [self.get_command(), '--vanilla', self._code]

initialize = Executor.initialize
{'fraction_non_alphanumeric': 0.18833118833118834, 'fraction_numerical': 0.003861003861003861, 'mean_word_length': 3.302583025830258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6667454', 'n_tokens_mistral': 813, 'n_tokens_neox': 783, 'n_words': 147}