Skip to content

Merge-squash SSL Certificate workaround and update to UAT #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions OpenAttack/attackers/uat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,22 @@ def __init__(self,

def set_triggers(self,
victim : Classifier,
dataset : datasets.Dataset,):
self.triggers = self.get_triggers(victim, dataset, self.tokenizer)
dataset : datasets.Dataset,
epoch : int = 5,
batch_size : int = 5,
trigger_len : int = 3,
beam_size : int = 5,
lang = None):

self.triggers = self.get_triggers(victim,
dataset,
self.tokenizer,
epoch=epoch,
batch_size=batch_size,
trigger_len=trigger_len,
beam_size=beam_size,
lang=lang
)

def attack(self, victim: Classifier, sentence : str, goal : ClassifierGoal):
trigger_sent = self.tokenizer.detokenize( self.triggers + self.tokenizer.tokenize(sentence, pos_tagging=False) )
Expand Down
8 changes: 6 additions & 2 deletions OpenAttack/utils/zip_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import zipfile
import os
from tqdm import tqdm

import ssl

def make_zip_downloader(URL : str, file_list=None, resource_name = None):
"""
Expand All @@ -28,7 +28,11 @@ def DOWNLOAD(path : str, source : str):
else:
name = resource_name

with urllib.request.urlopen(remote_url) as fin:
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

with urllib.request.urlopen(remote_url, context=ctx) as fin:
CHUNK_SIZE = 4 * 1024
total_length = int(fin.headers["content-length"])
with open(path + ".zip", "wb") as ftmp:
Expand Down