Skip to content

Commit 5d7f16e

Browse files
committed
docs: add contribution guidelines
1 parent 6f33cd1 commit 5d7f16e

File tree

5 files changed

+74
-37
lines changed

5 files changed

+74
-37
lines changed

CONTRIBUTING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Contributing to Coldwire project is simple, and is no different than any other Free and Open-Source project:
2+
3+
Simply fork the repo, hack on the code, and do a pull request!
4+
5+
**However**, some specific parts of **Coldwire** require *careful* thought before contributing changes
6+
7+
8+
## Protocol improvements and or adjustments
9+
Before hacking on our codebase to support a new protocol feature, or to improve an existing one.
10+
Coldwire depends on 2 seperate protocols: `Coldwire protocol`, and the `Strandlock protocol`
11+
12+
you *should* first read the related protocol specification, and modify it to reflect what you wish to be added / improved upon.
13+
14+
To summarize: Contributing major changes doesn't start with code, but with solid protocol improvements (that can be reasoned about), and that doesn't decrease our security posture (considering our threat model).
15+
16+
17+
## `browsers_headers.json`
18+
Before adding new entry, or modifying an existing one, please note that the *order* of the headers matters!
19+
**Do not** trust Developer tools on whatever browser you're using. The ordering of headers in a browser are not in the order that they are sent on the wire. Failure to do so, would actually create an even uniquer fingerprint of our users.
20+
21+
Additionally, all headers names must be lowercase for interoperability with HTTP/2
22+
23+
A very important note, is to **never** include any headers that may indicate to a server you're intending to receive compressed (gzip, etc) response!.
24+
25+
Do not misunderstand, *include* the header (i.e. accept-encoding), but do not put in it actual encoding names.
26+
27+
Instead, Spam "Coldwire" until the string reaches the same length of the intended "accept-encoding". Truncate "Coldwire" string as needed.
28+
29+
And lastly, please do not contribute obsecure browsers headers! Keep all additions to be popular, mainstream browsers.
30+
31+
32+
## Features that **will never be added**:
33+
Here are some features that we have decided against implementing after thoughtful consideration, as they overcomplicate the protocol, and increase the attack-surface in general:
34+
- Media parsing or sending in any of its forms (images, videos, SVGs, etc)
35+
- Text formating or markup languages support (rich text formating, etc.)
36+
- Multi-device support for the same account.
37+
- Open/Public groups
38+
- Voice, and video calls.
39+
- Voice messages
40+
- Compression support
41+
- Metadata-rich features (avatars, vanity server-side usernames, bios, delievery receipts, read receipts, online status, last seen status, user-created server authentication passwords)
42+
- Account recovery
43+
- Persistent chat history
44+
- Any "convenience" features that could impact security and or privacy (clickable URLs, keyboard hotkeys, keyboard shortscuts beyond the basic CTRL-C CTRL-V)

assets/browsers_headers.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"Microsoft-Edge": {
3+
"sec-ch-ua": "\"Not;A=Brand\";v=\"99\", \"Microsoft Edge\";v=\"139\", \"Chromium\";v=\"139\"",
4+
"sec-ch-ua-mobile": "?0",
5+
"sec-ch-ua-platform": "Windows",
6+
"upgrade-insecure-requests": "1",
7+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0",
8+
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
9+
"sec-fetch-site": "none",
10+
"sec-fetch-mode": "navigate",
11+
"sec-fetch-user": "?1",
12+
"sec-fetch-dest": "document",
13+
"accept-encoding": "ColdWireColdWireColdWir",
14+
"accept-language": "en-GB,en;q=0.9,en-US;q=0.8"
15+
}
16+
17+
}

core/requests.py

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def encode_file(name: str, filename: str, data: bytes, boundary: str, CRLF: str,
8080

8181

8282

83-
def http_request(url: str, method: str, auth_token: str = None, metadata: dict = None, blob: bytes = None, longpoll: int = None) -> bytes:
83+
def http_request(url: str, method: str, auth_token: str = None, metadata: dict = None, headers: dict = None, blob: bytes = None, longpoll: int = None) -> bytes:
8484
if method.upper() not in ["POST", "GET", "PUT", "DELETE"]:
8585
raise ValueError(f"Invalid request method `{method}`")
8686

@@ -113,22 +113,26 @@ def http_request(url: str, method: str, auth_token: str = None, metadata: dict =
113113
req = request.Request(
114114
url,
115115
data = body,
116-
headers={"Content-Type": f"multipart/form-data; boundary={boundary}"},
116+
headers={"content-type": f"multipart/form-data; boundary={boundary}"},
117117
method = method.upper()
118118
)
119119

120120
elif metadata:
121121
metadata = json.dumps(metadata).encode("utf-8")
122122
req = request.Request(url, data=metadata, method=method.upper())
123-
req.add_header("Content-Type", "application/json")
123+
req.add_header("content-type", "application/json")
124124
else:
125125
raise ValueError("Request method is POST/PUT but no metadata nor blob were given.")
126126

127127
else:
128128
req = request.Request(url, method=method.upper())
129129

130+
if headers is not None:
131+
for key, value in headers.items():
132+
req.add_header(key, value)
133+
130134
if auth_token is not None:
131-
req.add_header("Authorization", "Bearer " + auth_token)
135+
req.add_header("authorization", "Bearer " + auth_token)
132136

133137

134138
# NOTE: urllib raises a HTTPError for status code >= 400
@@ -143,32 +147,3 @@ def http_request(url: str, method: str, auth_token: str = None, metadata: dict =
143147

144148

145149

146-
147-
"""
148-
def http_request(url: str, method: str, auth_token: str = None, payload: dict = None, longpoll: int = -1) -> dict:
149-
if payload:
150-
payload = json.dumps(payload).encode()
151-
152-
if payload:
153-
req = request.Request(url, data=payload, method=method.upper())
154-
req.add_header("Content-Type", "application/json")
155-
else:
156-
req = request.Request(url, method=method.upper())
157-
158-
if auth_token:
159-
req.add_header("Authorization", "Bearer " + auth_token)
160-
161-
# NOTE: urllib raises a HTTPError for status code >= 400
162-
163-
try:
164-
if longpoll == -1:
165-
with request.urlopen(req) as response:
166-
return json.loads(response.read().decode())
167-
else:
168-
with request.urlopen(req, timeout=longpoll) as response:
169-
return json.loads(response.read().decode())
170-
except urllib.error.HTTPError as e:
171-
body = e.read().decode()
172-
logger.error("We received error from server: %s", body)
173-
raise Exception(body)
174-
"""

logic/smp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,6 @@ def smp_failure_notify_contact(user_data, user_data_lock, contact_id, ui_queue)
513513
)
514514
except Exception as e:
515515
logger.error("Failed to send SMP failure to contact (%s), either you are offline or the server is down. Error: %s", contact_id, str(e))
516-
pass
517516

518517

519518

ui/smp_question_window.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
smp_step_4_answer_provided,
88
smp_failure_notify_contact
99
)
10-
10+
from core.constants import (
11+
SMP_QUESTION_MAX_LEN
12+
)
1113
class SMPQuestionWindow(tk.Toplevel):
1214
def __init__(self, master, contact_id, question):
1315
super().__init__(master)
@@ -21,10 +23,10 @@ def __init__(self, master, contact_id, question):
2123
self.configure(bg="black")
2224

2325
# Question label
24-
# :512 to ensure no weird visual effects or even bufferoverflows can be exploited in the underlying tkinter library.
26+
# :SMP_QUESTION_MAX_LEN to ensure no weird visual effects or even bufferoverflows can be exploited in the underlying tkinter library.
2527
tk.Label(
2628
self,
27-
text="Question: " + question[:512],
29+
text="Question: " + question[:SMP_QUESTION_MAX_LEN],
2830
fg="white",
2931
bg="black",
3032
font=("Helvetica", 10),

0 commit comments

Comments
 (0)