So, I have been thinking about a LinkFilter
This is what I propose:
Config now has:
-A list of strings that is the LinkFilter
-Can be toggled with FilterIsAllow to function as an AllowList (set to true) or DenyList, (set to false)
-Has two messages. NotInAllowList and InDenyList, for when the user tries a not allowed/denied link.
There is now a signartist.overridefilter permission to override the LinkFilter available, for use by admins and such. They will have all links allowed.
The LinkFilter needs some Json to function with the config, so
under #region Config | Init | Unload added:Code:using Newtonsoft.Json;
In void OnServerInitialized() Added:Code:string InDenyList = "Link is in deny list. Try another or ask the admin."; string NotInAllowList = "Link is not in allow list. Try another or ask the admin."; bool FilterIsAllow = true; List<string> LinkFilter=new List<string>();
Then, just before 'RaycastHit hit;' in both void sil and void silt, I have:Code:permission.RegisterPermission("signartist.overridefilter", this); CheckCfg("Link in deny list msg", ref InDenyList); CheckCfg("Link not in allow list msg", ref NotInAllowList); CheckCfg("Link filter is allowlist", ref FilterIsAllow); CheckCfg("Link filter list", ref LinkFilter);
and some changes to the CheckCfg<T>, to make it convert lists of objects to lists of stringsCode:if (!HasPerm(player, "SignArtist.overridefilter"))//People with overridefilter permission set do not have to filter { if(FilterIsAllow)//empty list: allow all { if ((LinkFilter.Count>0) && (!IsUpperStringInList(args[0], LinkFilter)))//have allow list, but link is not in it { player.ChatMessage(NotInAllowList); Console.WriteLine(string.Format("{0} \nused not allowed link: \n{1} \n",player.userID, args[0])); return; } }else{//empty list: deny all if ((LinkFilter.Count==0) || (IsUpperStringInList(args[0],LinkFilter)))//list is empty, or link in list { player.ChatMessage(InDenyList); Console.WriteLine(string.Format("{0} \nused denied link: \n{1} \n",player.userID, args[0])); return; } } } RaycastHit hit;
and a util that does 'contains' but then with uppercaseCode:void CheckCfg<T>(string Key, ref T var) { if (Config[Key] == null) Config[Key] = var; else try { if (typeof(T).ToString()== "System.Collections.Generic.List`1[System.String]") { List<string> temp=new List<string>(); temp= JsonConvert.DeserializeObject<List<string>>(JsonConvert.SerializeObject(Config[Key])); var = (T)Convert.ChangeType(temp, typeof(T)); } else { var = (T)Convert.ChangeType(Config[Key], typeof(T)); } } catch { Config[Key] = var; } }
Note that having an empty LinkFilter and FilterIsAllow=true (which is the default), you will allow all.Code:bool IsUpperStringInList(string s, List<string> l) { string su = s.ToUpper(); foreach (string ls in l) { if (su.StartsWith(ls.ToUpper())) return true; } return false; }
While having an empty LinkFilter and FilterIsAllow=false, you will deny all.
Links are case insensitive.
So, what do you think, Nogrod. Add this or something like this to the code?
SignArtist
Moved
Total Downloads: 39,227 - First Release: Apr 29, 2015 - Last Update: Jan 19, 2018
- 4.88966/5, 145 likes
-
Anyone els since patch cant get it to upload pics? I get no error jsut dosent work
-
how do you gain permition to it
-
Wulf Community Admin
Grant the permissions desired that are listed on the Overview. Using Oxide's permission system | Oxide -
How to grab image from Linux file system?
-
Wulf Community Admin
/path/to/file/name.png -
let/me/rephrase.that
Windows I see your example "/sil file:///C:/Windows/test.png"
Linux file systems are little different, where do I start the path from?
Could you give me an example of a png file in the current user's home directory? -
Wulf Community Admin
/sil /full/path/to/file/name.png
or perhaps
/sil username/path/to/file/name.png -
you mean "/sil file:///root/home/username/images/file.png"
Or "....///home/username/images/file.png"
Or "...///~/images/file.png" -
Wulf Community Admin
I mean what I listed. I think file:// is generally Windows only. I've never used it like that though, so I can't guarantee it works. -
Trial and error. I got it.....
"/sil file:///home/username/folder(s)/image.png" -
Is there a permission or way to disable uploading images from the local machine? That is a security risk right there.
-
Wulf Community Admin
Don't grant the permission for that, instead only grant the signartist.url permission. -
What is the permission for that? It isn't listed on the overview.
-
Wulf Community Admin
That is the permission, and it is listed on the Overview at the bottom. -
... You're confusing. So what you are saying is signartist.url allows you to use URLs and files on the local machine? What is the permission for files on the local machine? This way I can make sure I don't grant it.
-
Wulf Community Admin
Sorry, I was wrong. I thought it was split, but apparently there is no way to prevent local files from being loaded. -
Oh okay, thanks for clarifying. Would you be able to fix this in the next update?
-
Wulf Community Admin
I'm not the author of this plugin, so that'd be up to @Nogrod. -
Oops
. You are the author of half the plugins on
here.
