Repository: vertexproject/synapse

Issue:
[BUG] inet:url not stripping whitespace at the beg
**Describe the bug**
When adding an inet:url node, whitespace is not stripped from the beginning of the str. I couldn't think of a reason that should be allowed. It would help any accidental spacing added by the user. Maybe this is a feature request then?  


**To Reproduce**
`cli> storm [inet:url=" https://x=msn.com"]
Executing query at 2020/05/22 18:12:49.545
.......
inet:url= https://msn.com
        .created = 2020/05/22 18:12:49.559
        :base =  https://msn.com
        :fqdn = msn.com
        :params =
        :path =
        :proto =  https
complete. 1 nodes in 16 ms (62/sec).
cli> storm [inet:url="  https://msn.com"]
Executing query at 2020/05/22 18:12:55.072
.......
inet:url=  https://msn.com
        .created = 2020/05/22 18:12:55.085
        :base =   https://msn.com
        :fqdn = msn.com
        :params =
        :path =
        :proto =   https
complete. 1 nodes in 14 ms (71/sec).`
A clear and concise description of what you expected to happen.

**Environment (please complete the following information):**
 - OS: macos
 - Synapse Version 0.2.0rc16
 - Python Version: 3.7.3
 - Output of `python -m pip freeze`
aiohttp==3.6.2
async-timeout==3.0.1
attrs==19.3.0
cffi==1.14.0
chardet==3.0.4
cryptography==2.9
fastjsonschema==2.14.4
idna==2.9
lark-parser==0.7.8
lmdb==0.98
msgpack==0.6.2
multidict==4.7.5
packaging==20.3
prompt-toolkit==2.0.10
pycparser==2.20
Pygments==2.3.1
pyOpenSSL==19.1.0
pyparsing==2.4.6
PyYAML==5.3.1
regex==2020.2.20
six==1.14.0
synapse==0.2.0rc16
tornado==6.0.4
wcwidth==0.1.9
xxhash==1.4.3
yarl==1.4.2



Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/vertexproject/synapse/pull/3940?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 94.35%. Comparing base [(`b5cc320`)](https://app.codecov.io/gh/vertexproject/synapse/commit/b5cc3206b4a0620ccbf75d560f93855f202e14ad?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject) to head [(`29d3223`)](https://app.codecov.io/gh/vertexproject/synapse/commit/29d3223ac383a72a7fda5e65b59ff0d11937068a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject).

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff              @@
##           synapse-3xx    #3940   +/-   ##
============================================
  Coverage        94.34%   94.35%           
============================================
  Files              243      243           
  Lines            57619    57620    +1     
============================================
+ Hits             54359    54365    +6     
+ Misses            3260     3255    -5     
```

| [Flag](https://app.codecov.io/gh/vertexproject/synapse/pull/3940/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject) | Coverage Δ | |
|---|---|---|
| [linux](https://app.codecov.io/gh/vertexproject/synapse/pull/3940/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject) | `94.35% <100.00%> (+<0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/vertexproject/synapse/pull/3940?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vertexproject).


Patch:
diff --git a/synapse/models/inet.py b/synapse/models/inet.py
index 624603cd6..f85565170 100644
--- a/synapse/models/inet.py
+++ b/synapse/models/inet.py
@@ -868,6 +868,7 @@ class Url(s_types.Str):
         return cmpr
 
     def _normPyStr(self, valu):
+        valu = valu.strip()
         orig = valu
         subs = {}
         proto = ''


Test patch:
diff --git a/synapse/tests/test_model_inet.py b/synapse/tests/test_model_inet.py
index d095983aa..3d484dd61 100644
--- a/synapse/tests/test_model_inet.py
+++ b/synapse/tests/test_model_inet.py
@@ -1414,6 +1414,18 @@ class InetModelTest(s_t_utils.SynTest):
             }})
             self.eq(valu, expected)
 
+            url = '  http://0.0.0.0/index.html?foo=bar  '
+            valu = t.norm(url)
+            expected = (url.strip(), {'subs': {
+                'proto': 'http',
+                'path': '/index.html',
+                'params': '?foo=bar',
+                'ipv4': 0,
+                'port': 80,
+                'base': 'http://0.0.0.0/index.html'
+            }})
+            self.eq(valu, expected)
+
             unc = '\\\\0--1.ipv6-literal.net\\share\\path\\to\\filename.txt'
             url = 'smb://::1/share/path/to/filename.txt'
             valu = t.norm(unc)