Commit graph

609 commits

Author SHA1 Message Date
Maybe Waffle
05603560e6 Give a name to a magic number and document it 2022-04-03 14:47:10 +04:00
Maybe Waffle
daec5ee13e Hide bot token in errors
This fixes a potential[^1] security vulnerability -- if bot shows errors
from teloxide to the user & for some reason network error happened[^2]
the url of the request would be included in the error. Since TBA
includes bot token in the error this may lead to token leakage.

This commit fixes that issue by removing the token from the urls of
`reqwest::Error`, we try to only replace the token, but if we fail we
remove the whole url.

This can be tested by using a very low timeout value for the http
reqwest client:
```rust
let client = reqwest::Client::builder()
    .timeout(std::time::Duration::from_millis(1))
    .build()
    .unwrap();

let bot = Bot::from_env_with_client(client).auto_send();

// see if the token is redacted when network error (timeout) happens
// while sending common requests
let _ = dbg!(bot.get_me().await);

// see if the token is redacted when network error (timeout) happens
// while downloading files ("path" is unimportant as the timeout is so
// low the request probably won't even be sent)
let _ = dbg!(bot.download_file_stream("path").next().await);
```

For me this gives the following result:
```text
[t.rs:26] bot.get_me().await = Err(
    Network(
        reqwest::Error {
            kind: Request,
            url: Url {
                scheme: "https",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: Some(
                    Domain(
                        "api.telegram.org",
                    ),
                ),
                port: None,
                path: "/token:redacted/GetMe",
                query: None,
                fragment: None,
            },
            source: TimedOut,
        },
    ),
)
[t.rs:31] bot.download_file_stream("path").next().await = Some(
    Err(
        reqwest::Error {
            kind: Request,
            url: Url {
                scheme: "https",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: Some(
                    Domain(
                        "api.telegram.org",
                    ),
                ),
                port: None,
                path: "/file/token:redacted/path",
                query: None,
                fragment: None,
            },
            source: TimedOut,
        },
    ),
)
```

Note that this commits parent is `d0be260` and not the current master
the master branch currently contains breaking changes (we'll need to
make a release from this brach directly).

[^1]: Note that there are recorded cases where the token got exposed.
[^2]: Note that this can be theoretically be controlled by the user when
      sending/downloading bigger files.
2022-04-03 13:34:17 +04:00
Hirrolot
d0be260575
Merge pull request #191 from teloxide/r044
Release 0.4.4
2022-03-21 08:27:02 -07:00
Maybe Waffle
1a61d02858 Release 0.4.4 2022-03-21 19:22:22 +04:00
Waffle Maybe
36a54a86e4
Merge pull request #190 from teloxide/not_found_error
Add `NotFound` error
2022-03-21 19:15:29 +04:00
Maybe Waffle
923be2221d Add NotFound error 2022-03-21 19:10:12 +04:00
Waffle Maybe
961e5aef9d
Merge pull request #189 from teloxide/with_payload
Add `HasPayload::with_payload_mut` function
2022-03-20 19:12:31 +04:00
Hirrolot
2c0748f3ae
Merge branch 'master' into with_payload 2022-03-20 08:08:52 -07:00
Waffle Maybe
0e4163d3c5
Merge pull request #188 from teloxide/new_errors_just_dropped
Add `WrongFileIdOrUrl` and `FailedToGetUrlContent` errors
2022-03-19 21:09:30 +04:00
Maybe Waffle
d8e3c6ce42 Add WrongFileIdOrUrl and FailedToGetUrlContent errors 2022-03-18 14:21:55 +04:00
Maybe Waffle
c7e32fa247 Add HasPayload::with_payload_mut function
`HasPayload::with_payload_mut` allows to easily apply multiple changes
to the payload without calling `payload_mut()` multiple times and
creating temporary variable for the request. e.g.:
```rust
// without `with_payload_mut`
{
    let mut req = bot.set_webhook(url.clone());

    req.payload_mut().certificate = certificate.take();
    req.payload_mut().drop_pending_updates = drop_pending_updates;

    req.send().await?;
}

// with `with_payload_mut`
bot
    .set_webhook(url.clone())
    .with_payload_mut(|payload| {
        payload.certificate = certificate.take();
        payload.drop_pending_updates = drop_pending_updates;
    })
    .send()
    .await?
```
2022-03-18 14:13:38 +04:00
Hirrolot
7437a8c4a8
Merge pull request #187 from teloxide/r043
Release 0.4.3
2022-03-08 00:47:37 +06:00
Maybe Waffle
11c79499e3 Release 0.4.3 2022-03-07 22:43:24 +04:00
Waffle Maybe
0c5f9678d8
Merge pull request #185 from teloxide/revert_better_timeouts
Revert "better timeouts"
2022-03-07 20:16:53 +04:00
Waffle Maybe
1643632539
Merge pull request #186 from teloxide/user_is_automatic
Add `User::is_telegram` function
2022-03-07 20:16:25 +04:00
Maybe Waffle
b0607f604a update changelog 2022-03-03 02:23:46 +03:00
Maybe Waffle
5fb0a4787f fix typos 2022-03-03 02:23:46 +03:00
Maybe Waffle
fbbb5c842b Add User::is_telegram 2022-03-03 02:23:40 +03:00
Maybe Waffle
9eb51ad34b fix clippy 2022-03-03 02:21:52 +03:00
Maybe Waffle
cfb48a6fa4 Update changelog 2022-03-03 01:48:09 +03:00
Maybe Waffle
d5ad882999 fix typos 2022-03-03 01:45:41 +03:00
Maybe Waffle
812f6ef45e Revert buggy "better timeouts" 2022-03-03 01:43:25 +03:00
Waffle Maybe
3f2906df62
Merge pull request #184 from mikhailantoshkin/master
Add missing enum variants to the `Update::chat()`
2022-02-20 21:22:47 +03:00
mikhailantoshkin
3c09f32723
Update changelog 2022-02-20 23:17:15 +05:00
mikhailantoshkin
686ec23b76
Add missing enum variants to the chat fucntion 2022-02-20 22:56:29 +05:00
Hirrolot
489499218c
Merge pull request #183 from teloxide/r042
Prepare `0.4.2` release
2022-02-17 18:19:17 +06:00
Maybe Waffle
1d7825c97a Prepare 0.4.2 release 2022-02-17 15:03:41 +03:00
Waffle Maybe
b079722ce2
Merge pull request #182 from teloxide/deprecate_chat_id
Deprecate `Message::chat_id`
2022-02-17 14:55:43 +03:00
Maybe Waffle
6bf204221f Deprecate Message::chat_id 2022-02-17 14:51:00 +03:00
Waffle Maybe
016763cf8c
Merge pull request #181 from teloxide/poll_fix
Fix sending quiz polls
2022-02-17 14:18:15 +03:00
Maybe Waffle
3477f7eded Fix sending quiz polls 2022-02-17 14:10:39 +03:00
Waffle Maybe
6113bce6e5
Merge pull request #180 from teloxide/payload_timeout_hint
Add a way for long-running requests to increase network timeout
2022-02-17 06:11:01 +03:00
Maybe Waffle
fb7710b838 Make GetUpdates expose its timeout via Payload::timeout_hint 2022-02-14 19:53:19 +03:00
Maybe Waffle
2dc4a915ba Add a way for long-running requests to increase network timeout 2022-02-14 19:52:43 +03:00
Waffle Maybe
fb53a82611
Merge pull request #179 from teloxide/r041
Release `0.4.1`
2022-02-13 21:13:30 +03:00
Maybe Waffle
bfb64665a6 Release 0.4.1 2022-02-13 21:08:40 +03:00
Waffle Maybe
a28bd4a4c1
Merge pull request #178 from teloxide/until_fixed
Fix `UntilDate` deserialization
2022-02-13 21:06:00 +03:00
Maybe Waffle
8d89fdccbd Fix Update de/serialization tests 2022-02-13 20:58:33 +03:00
Maybe Waffle
c0795f0dc9 Add regression test for issue 523 2022-02-13 20:53:58 +03:00
Maybe Waffle
fb523f153e Fix deserialization of UntilDate 2022-02-13 20:53:41 +03:00
Hirrolot
b60caab9dd
Merge pull request #177 from teloxide/r040
Dump version (-> 0.4.0)
2022-02-03 21:05:15 +06:00
Maybe Waffle
4f85b8dc03 Dump version (-> 0.4.0) 2022-02-03 17:48:36 +03:00
Waffle Maybe
d83f7180c4
Merge pull request #175 from teloxide/tba_5.7
TBA 5.7
2022-02-03 17:39:16 +03:00
Waffle Maybe
1c2a38eeb6
Merge pull request #173 from teloxide/docs_examples_blah
Change process of building docs
2022-02-03 17:38:52 +03:00
Waffle Maybe
6618aaf48d
Merge pull request #176 from Flattergaster/master
Fix deserialization of `ChatInviteLink::pending_join_request_count`
2022-02-02 23:04:57 +03:00
Flattergaster
82eb96b405 Fix deserialization of ChatInviteLink::pending_join_request_count 2022-02-02 22:38:03 +03:00
Maybe Waffle
c34a1386df Fix test 2022-02-01 21:14:09 +03:00
Maybe Waffle
1ae7544578 Update changelog 2022-02-01 20:22:20 +03:00
Maybe Waffle
044f33551e TBA 5.7: Add Sticker{,Set}::is_video 2022-02-01 20:12:26 +03:00
Maybe Waffle
6384560195 TBA 5.7: Add InputSticker::Webm 2022-02-01 19:39:29 +03:00