@cryptotaxi247 / CoPilot / commits / 31cf27da

swagger config for sublime endpoint (#13)

taylor_socfortress committed Jul 12, 2023 at 14:08 UTC 31cf27dac3181ea3cc706f90f6641f5466a6c6a4
2 files changed +200 -3
backend/app/routes/sublime.py
+3 -3
@@ -28,10 +28,10 @@ def put_alert() -> jsonify:
28 try:
29 message_id = service.validate_payload(data=data)
30 service.store_alert(message_id=message_id)
31 - return jsonify({"message": "Successfully stored payload.", "success": True}), 200
31 + return jsonify({"message": "Successfully stored message ID.", "success": True}), 200
32 except InvalidPayloadError:
33 - logger.error("Received invalid payload.")
34 - return jsonify({"message": "Invalid payload.", "success": False}), 400
33 + logger.error("Received invalid payload. No message ID found.")
34 + return jsonify({"message": "Invalid payload. No message ID found", "success": False}), 400
35
36
37 @bp.route("/sublime/alerts", methods=["GET"])
backend/app/static/swagger.json
+197
@@ -73,6 +73,14 @@
73 "description": "Find out more",
74 "url": "http://swagger.io"
75 }
76 + },
77 + {
78 + "name": "Sublime",
79 + "description": "Everything about Sublime",
80 + "externalDocs": {
81 + "description": "Find out more",
82 + "url": "http://swagger.io"
83 + }
84 }
85 ],
86 "paths": {
@@ -1821,6 +1829,195 @@
1829 "operationId": "getAllAlerts",
1830 "tags": ["DFIR Iris"]
1831 }
1832 + },
1833 + "/sublime/alerts": {
1834 + "get": {
1835 + "summary": "Get all alerts",
1836 + "description": "Endpoint to get all alerts.",
1837 + "responses": {
1838 + "200": {
1839 + "description": "Successful operation",
1840 + "content": {
1841 + "application/json": {
1842 + "schema": {
1843 + "type": "object",
1844 + "properties": {
1845 + "alerts": {
1846 + "type": "array",
1847 + "items": {
1848 + "type": "object",
1849 + "description": "Alert details"
1850 + }
1851 + }
1852 + }
1853 + }
1854 + }
1855 + }
1856 + },
1857 + "default": {
1858 + "description": "Unexpected error",
1859 + "content": {
1860 + "application/json": {
1861 + "schema": {
1862 + "$ref": "#/components/schemas/Error"
1863 + }
1864 + }
1865 + }
1866 + }
1867 + },
1868 + "operationId": "getAllAlerts",
1869 + "tags": ["Sublime"]
1870 + }
1871 + },
1872 + "/sublime/alert": {
1873 + "post": {
1874 + "summary": "Create an alert",
1875 + "description": "Endpoint to create an alert.",
1876 + "requestBody": {
1877 + "description": "Alert details",
1878 + "content": {
1879 + "application/json": {
1880 + "schema": {
1881 + "type": "object",
1882 + "properties": {
1883 + "api_version": {
1884 + "type": "string",
1885 + "example": "1"
1886 + },
1887 + "created_at": {
1888 + "type": "string",
1889 + "format": "date-time",
1890 + "example": "2023-06-28T20:45:01.619833409Z"
1891 + },
1892 + "data": {
1893 + "type": "object",
1894 + "properties": {
1895 + "flagged_rules": {
1896 + "type": "array",
1897 + "items": {
1898 + "type": "object",
1899 + "properties": {
1900 + "id": {
1901 + "type": "string",
1902 + "example": "1845f3e6-e446-4f1a-b256-83539f850ed3"
1903 + },
1904 + "name": {
1905 + "type": "string",
1906 + "example": "Test rule"
1907 + },
1908 + "severity": {
1909 + "type": "string",
1910 + "nullable": true
1911 + },
1912 + "tags": {
1913 + "type": "array",
1914 + "items": {
1915 + "type": "string"
1916 + }
1917 + }
1918 + }
1919 + }
1920 + },
1921 + "message": {
1922 + "type": "object",
1923 + "properties": {
1924 + "canonical_id": {
1925 + "type": "string",
1926 + "example": "c6a577585601e9ac17c949a33f73956ec7ee9f2ad1c4209d7e69dda819a62969"
1927 + },
1928 + "external_id": {
1929 + "type": "string",
1930 + "example": "29082"
1931 + },
1932 + "id": {
1933 + "type": "string",
1934 + "example": "4a29ffda-3efe-4418-b9a0-c4e40878b7c5"
1935 + },
1936 + "mailbox": {
1937 + "type": "object",
1938 + "properties": {
1939 + "external_id": {
1940 + "type": "string",
1941 + "nullable": true
1942 + },
1943 + "id": {
1944 + "type": "string",
1945 + "example": "e921c909-e72a-4c9c-b56c-0dd59c7f49c3"
1946 + }
1947 + }
1948 + },
1949 + "message_source_id": {
1950 + "type": "string",
1951 + "example": "d4bc5aef-ee26-4c54-a43e-de5faa794575"
1952 + }
1953 + }
1954 + },
1955 + "triggered_actions": {
1956 + "type": "array",
1957 + "items": {
1958 + "type": "object",
1959 + "properties": {
1960 + "id": {
1961 + "type": "string",
1962 + "example": "2c16da90-6f79-496b-886a-bf382423762a"
1963 + },
1964 + "name": {
1965 + "type": "string",
1966 + "example": "Shuffle"
1967 + },
1968 + "type": {
1969 + "type": "string",
1970 + "example": "webhook"
1971 + }
1972 + }
1973 + }
1974 + }
1975 + }
1976 + },
1977 + "id": {
1978 + "type": "string",
1979 + "example": "30aae129-ec7a-4797-bcd4-a1e6e924e5db"
1980 + },
1981 + "type": {
1982 + "type": "string",
1983 + "example": "message.flagged"
1984 + }
1985 + }
1986 + }
1987 + }
1988 + }
1989 + },
1990 + "responses": {
1991 + "200": {
1992 + "description": "Successful operation",
1993 + "content": {
1994 + "application/json": {
1995 + "schema": {
1996 + "type": "object",
1997 + "properties": {
1998 + "alert": {
1999 + "type": "object",
2000 + "description": "Alert details"
2001 + }
2002 + }
2003 + }
2004 + }
2005 + }
2006 + },
2007 + "default": {
2008 + "description": "Unexpected error",
2009 + "content": {
2010 + "application/json": {
2011 + "schema": {
2012 + "$ref": "#/components/schemas/Error"
2013 + }
2014 + }
2015 + }
2016 + }
2017 + },
2018 + "operationId": "createAlert",
2019 + "tags": ["Sublime"]
2020 + }
2021 }
2022 },
2023 "components": {